2

I have a simple ASP.NET Webapplication project with url-routing and want to "allow" routes with the fileextension like ".html", e.g...

http://www.mywebsite.com/cms/test.html
http://www.mywebsite.com/cms/sub/test.html
http://www.mywebsite.com/cms/sub/sub/test.html

My global.asax routes looks like this:

routes.MapPageRoute("", "cms/{a1}", "~/default.aspx");

The route is matched with when i access the website like this: http://www.mywebsite.com/cms/test

If i try this one, it doens't work too:

routes.MapPageRoute("", "cms/{a1}.html", "~/default.aspx");

EDIT: Always i get an 404 error. I think that .net looks for the physical file...

Any ideas?

3
  • You should verify if IIS isn't routing these request before .NET working process. Commented May 2, 2013 at 16:40
  • How can i do this? In the Mime-Types properties? Commented May 2, 2013 at 16:46
  • The easiest troubleshoot is to place a HTML file on the path you're routing to and test if its called. If you keep getting 404, then there's nothing to do with IIS and the problem is with your route. Otherwise, it's IIS getting in your way. Commented May 2, 2013 at 21:45

1 Answer 1

3

I've fixed it on my on with the following property "runAllManagedModulesForAllRequests" inside the like this:

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="UrlRoutingHandler" />
    </handlers> 
  </system.webServer>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much. This was driving me crazy for a long time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.