MVC project routing is not routing .html to custom routes

106 Views Asked by At

I have added a route for "privacy.html" to route to Home/Privacy in my ASP.Net MVC project. I've used this in other projects successfully, but it won't work in this one.

        routes.MapRoute(
            name: "privacy.html",
            url: "privacy.html",
            defaults: new { controller = "Home", action = "Privacy" }
        );

I've added the Route Debugger, and on all pages in the site it shows me the routing table at the end of the page, but it doesn't show on privacy.html. It shows a 404 error "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

I'm at a complete loss. It's like my local IIS (and server IIS 7.5) aren't using the routing table for the *.html requests.

1

There are 1 best solutions below

1
chsword On

you can try

  <system.webServer>
    <handlers>
      <add name="html" verb="*" path="*.html" type="System.Web.Mvc.MvcHttpHandler" />
    </handlers>
  </system.webServer>

in web.config