Html.BeginForm and Html.BeginRouteForm generate empty action urls

Posted by

Using the Html.BeginForm and Html.BeginRouteForm I had a situation tonight where on my production server all the form tags where generated as <form action=”” method=”post” even thought controller and action were properly defined!  Found this post ..

which directed me to the fact that I had recently added a param to the default route 

routes.MapRoute(“Default”, “{controller}/{action}/{id}/{section}”, new { controller = “Home”, action = “Index”, id = “”, section=”” } );

I still don’t understand why, but this causes the html helper to generate an empty action url as it cannot map the generated url to any route!!??   The temp fix I currently implemented (and is hopefully saving my a## untill tomorrow) is to add the Default “Default” url after the modified default url 🙂 

 routes.MapRoute(“DefaultOrginal”,”{controller}/{action}/{id}”,new { controller = “Home”, action = “Index”, id = “” }

One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s