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
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With