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?

2
  • 1
    stackoverflow.com/questions/9331516/… Commented Jan 20, 2014 at 6:39
  • Thanks its resolved my problem. Please explian code <add path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" /> </httpHandlers> Commented Jan 20, 2014 at 8:43

1 Answer 1

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

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.