I'm on my first MVC project and still haven't got a complete hang of it. I ran into this issue:
I have this in my View (Home/Index.aspx)
<% using (Html.BeginForm()) { %>
<fieldset>
<p>
<%: Html.TextBox("A")%>
<%: Html.TextBox("B") %>
<%: Html.ActionLink("Submit", "Create", "Home")%>
</p>
</fieldset>
<% } %>
I have this in my Controller (Controllers/HomeController.cs)
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(FormCollection formValues)
{
return View("Index");
}
I haven't changed the default routes in global.asx
When I hit submit, I get the "The resource cannot be found error". However, if I change the ActionLink to
<input type="submit" value="Save" />
and the method in the controller to:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection formValues)
{
return View("Index");
}
it works fine.
I'm a little confused because if I'm specifying the exact action method name and the controller in the ActionLink (<%: Html.ActionLink("Submit", "Create", "Home")%> ), why would it matter whether I name this method Create or Index?