I have two routes defined thus:
//Custom route for legacy admin page
routes.MapPageRoute(
"LocaliseRoute", // Route name
"Admin/Localise", // URL
"~/Views/Admin/Localise.aspx" // File
);
routes.MapRoute(
"Admin", // Route name
"Admin/{action}/{id}", // URL with parameters
new { controller = "Admin", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
both the following GETs work fine:
http://pegfect.local/Admin/PegModelUpload
http://pegfect.local/Admin/Localise
However, the form action of the former is /Admin/Localise?action=UploadPegModel&controller=Admin
resulting in an expression of “WTF?!”
the code for the form is:
@using (Html.BeginForm("UploadPegModel", "Admin", FormMethod.Post, new { enctype = "multipart/form-data", onsubmit = "return validateForm();" }))
{
<input type='file' name='file' id='file' />
<input type="submit" value="submit" />
}
The answer is right here: http://bartwullems.blogspot.co.uk/2011/04/combining-aspnet-webforms-and-aspnet.html
Answers on a postcard as to why this would work…