I have an ASP.Net MVC 2 application that serves up static HTML files as an actionresult
Content(htmlString);
This HTML contains relative links within it. i.e. /absdk123.html?t1=somevalue&t2=someothervalue
What should my route look like to match these HTTP requests? I have tried this:
routes.MapRoute(
"LinkRoute", // Route name
"{html}", // URL with parameters
new { controller = "Home", action = "ResolveLink"} // Parameter defaults
);
At the action, "ResolveLink" the string parameter is always ‘null’. How can I write a route to correctly handle these links?
public ActionResult ResolveLink(string htmlFileName)
{
//test param
return Content(htmlFileName);
}
This will actually match any request of format /{filename}.html.
I didn’t realize that a file extension could be included in a route.