The AspNet MVC Route parsing adds the. html suffix 404 Error Resolution

Source: Internet
Author: User

Using MVC sometimes we hope that the browse address ends with a suffix named. html. htm.

So we modify the routing configuration information in the Routeconfig, and the modified code is as follows

Routes. Ignoreroute ("{Resource}.axd/{*pathinfo}"); Routes. MapRoute (Name:"Default", URL:"{controller}/{action}.html", defaults:New{controller =" Public", action ="Login", id =urlparameter.optional});

But when the visit, tip 404, how to do that? Where is the problem, check out the simplest way to:

On the web. New configuration in config

New Under System.webserver

<modules runallmanagedmodulesforallrequests= "true" ></modules> OK

The explanations are as follows:

What the hell is runallmanagedmodulesforallrequests?

It means a switch for all Modules management requests, if set to true, that is, all requests to the Modules channel through, there is no block, then what is Modules? The literal meaning can be understood as "module" or "unit" meaning, it is something belonging to the Web server, and the Web application is not very relevant, the Web application just to launch a request for it, Modules related things, you can look at this very good article: IIS Modules Overview.

Summary: There should be other solutions to the problem of 404 routing resolution, and this approach is also flawed.

Reference URL: http://www.mamicode.com/info-detail-448415.html

The AspNet MVC Route parsing adds the. html suffix 404 Error Resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.