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
  • 58,060
  • 25
  • 98
  • 150

1 Answers1

1
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
  • 19,175
  • 2
  • 63
  • 83
Manish Singh
  • 934
  • 1
  • 12
  • 27