urlmappings and URL Mappings

Source: Internet
Author: User

The purpose of this configuration section is to add a map of the URLs to the Web program so that the user accesses the mapped URL (such as/PAGE/AAA) and also accesses the effect of the source URL (such as/page/pageaaa.aspx). This is also the URL mapping of the original role.

Detailed configuration is as follows

Where you want to enable this URL mapping, the URLs that must have the enabled set to True,add and remove are the mapped URLs.

At first I was trying in the WebForm, the result was successful, and then I feared that it would be obsolete under MVC, and it might be that some reason could not be mapped at first, and the URL could not be found directly. And then we estimate the break point. A look at two applications (WebForm and MVC) application contains Urlmappingsmodule. Then try it out under MVC, and somehow the mapping succeeds. However, it is also found that this URL mapping is the function of this module in the HTTP pipeline of ASP.

For ignorance of me, let me to implement a urlmappingsmoduel implementation mapping, most will use the HttpResponse redirt through the URL redirection to achieve the effect of this URL mapping from the surface implementation. When I first started to learn ASP. HttpResponse's Redirt is the page jump, understand the HTTP protocol time only to find that these two are still different.

First get a redirect example, there is an action he is redirected to another action--helloworld inside

When visiting this redhelloworld, the Web request is seen through Google's developer tools.

The page is eventually accessed to HelloWorld. However, this is not a response to request Redhelloworld, the response, such as a status code 302 for redirection, through the "/home/helloworld" field inside the site to initiate the request again, the final display of the page is HelloWorld response content.

(This suddenly became in the said HTTP protocol, grade felt a lot lower)

Look at the URL mapping again, add the following configuration in Web. config

When accessing/ABC/AAA, the content of/home/index is presented, and the response header is such that the

For this I also specifically looked at the source code, first of all, the configuration of Web. config is definitely by a section suffix of the configuration read class to get, then here is urlmappingssection. It reads the entire mapping information and then stores it in a collection of Urlmappingcollection, named Urlmappings.

This set will be used in two places, one is Urlmappingsmodule and the other is in Applicationstepmanager. The specific role of this applicationstepmanager I did not go seriously, but through the httpapplication inside a bit of code speculation, this is used in Classic mode, the other pipeline should be the corresponding integration mode. If I'm wrong here, the other great gods can shoot bricks, and I'd be happy to change them.

That said back to urlmappingsmodule inside, he is registered HttpApplication beginrequest event, whenever there is a request to come when he will be the URL of the request to get past urlmappings than to see there is no mapping,

If there is, then call HttpContext inside the RewritePath method to rewrite the request path, this rewritepath is a public method

For httpresponsed It changes the status code to 301 or 302 in the response header, and then notes the Location field, and extracts the internal method from the HttpResponse redirect overload.

There's actually another way of responding, he's got something to do with WebForm, and you don't need it when you use MVC.

urlmappings and URL Mappings

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.