0

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?

tereško
  • 57,247
  • 24
  • 95
  • 149

1 Answers1

0
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

Joel
  • 18,947
  • 2
  • 62
  • 82
Manish Singh
  • 884
  • 1
  • 12
  • 26