I see that my problem is a common mistake and tried many times to answer this problem, but it still does not work for me. So, to start forming the beginning, I have a partial form in an MVC project that uses the Html.BeginForm helper:
<%using (Html.BeginForm("MyAction", "MyController", FormMethod.Post, new{@class = "form-class"}))
"MyAction" and "MyController" are not actual names, but they are allowed, as confirmed names confirm. My action in my controller:
[HttpPost] public ActionResult MyAction(int id, FormCollection form) { EditedData dt = new EditedData();
So the common problem seems to be that using [HttpPost] returns a "Resource not found" error. I debugged with [HttpPost] a comment that removes MyAction so that it does not route (?). global.asax has not been changed:
public class MvcApplication : System.Web.HttpApplication { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default",
As I said, I tried other answers in other posts that seem to work on the poster, but I still have a problem. What am I missing?
PS In View Source, I see a form tag read:
<form method="post" action="690" id="form1">
when the action should point to MyAction. How to install Html.BeginForm to point to "MyAction"?
source share