Skip to main content

ASP.NET MVC: Route a .html request to an MVC route

For a SPA application I’m building I need to accept requests to .html files although I didn’t use static html files but razor views instead. To get this working inside ASP.NET MVC is a little bit harder than you would expect. So here are the required steps:

  • Add a handler mapping  in your web.config that will point *.html requests to the TransferRequestHandler. Therefore add the following section to the<system.webServer> node:
  • Add a custom route. Open up App_Start/RouteConfig.cs and it to the RegisterRoutes call: