Html.BeginForm and Html.BeginRouteForm generate empty action urls

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 .. 

http://stackoverflow.com/questions/1003040/asp-net-mvc-html-beginform-problem

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 thought on “Html.BeginForm and Html.BeginRouteForm generate empty action urls

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s