Wednesday, March 26, 2014

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:

3 comments:

James Brown said...

Thanks for taking the time to that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us.
video and blog marketing

Barbie Chiu said...

Good day! I found your site very interesting and informative . Thanks for taking time sharing it with us. I really enjoyed reading your post.

triciajoy.com

www.triciajoy.com

Mary Brown said...

Great Article

MVC 5 Training
Online MVC Training