Reproducing a bug

time to read 2 min | 264 words

Create new ASP.Net MVC application:

image

Create an action that take non nullable argument called 'id':

[HandleError]
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewData["Title"] = "Home Page";
        ViewData["Message"] = "Welcome to ASP.NET MVC!";

        return View();
    }

    public ActionResult Test(int id)
    {
        return Content(id.ToString());
    }

    public ActionResult About()
    {
        ViewData["Title"] = "About Page";

        return View();
    }
}

Go to home/index.aspx and add the following before the final </asp:Content> tag:

    <% using(Html.BeginForm("Test","Home")){ %>
        <%=Html.Hidden("id",2) %>
        <input type="submit" value="test" />
    <%} %>

Visit the site and see that you indeed have a test button on the page. Click the button.

Get an exception:

image

I am going to assume this is a bug.

This is on the ASP.Net MVC beta bits.