Reputation: 21
Controller Name is : TestController
Action Name is :HtmlContent
and Url : localhost:53907/en_US/Index.html
I would like to call HtmlContent action from TestController if url which contains .html extension.
I have placed breakpoint in HtmlContent but its not hitting if i enter url like mentioned above,
routes.MapRoute(
name: "MyCustomRoute",
url: "en_US/{pagename}",
defaults: new { controller = "Test", action = "HtmlContent" },
constraints: new {pagename = @".*?$(?<=\.html)" }
);
How to write routing for this requirement?
Upvotes: 0
Views: 2312
Reputation: 1004
routes.MapRoute(
name: "MyCustomRoute",
url: "en_US/{pagename}.html",
defaults: new { controller = "Test", action = "HtmlContent" },
constraints: new {pagename = @".*?$(?<=\.html)" }
);
and add code on web.config
<add name="HtmlFileHandler" path="*.html" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
its work for me if any query .please comment
Upvotes: 1