6

I develop a web application with ASP.NET MVC. I have problem with route.

I need a route like this. http://localhost/content-name/23.html

I've defined a route for this as follows

//i need this route but it's not work
routes.MapRoute(
"GetContent",
"{sefLink}/{contentId}.html",
new { controller = "Content", action = "GetContent" },
new[] { "CanEcomm.Controllers" });

But the route doesn't work. IIS is showing me 404 page. When i remove .html extension so the route works.

//this route is working. i just remove ".html" extension
routes.MapRoute(
    "GetContent",
    "{sefLink}/{contentId}",
    new { controller = "Content", action = "GetContent" },
    new[] { "CanEcomm.Controllers" });

How can i solve this? Thank you

1 Answer 1

5

I've added HtmlFileHandler to my web.config. And .html routes work now.

<handlers>
  <add name="HtmlFileHandler" path="*.html" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>    
Sign up to request clarification or add additional context in comments.

Comments

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.