Use the URL mapping of ASP.net 2.0

Source: Internet
Author: User
Tags config new features advantage
asp.net introduction:

URL mapping is the new feature provided in ASP.net 2.0. URL mapping technology helps us map a particular URL to another URL. To help understand, let's say you have a page called Homepage.aspx on the site to access the homepage, and all users will use this page to access your homepage. But for some reason, you should change the homepage to originalhome.aspx. Using URL mapping allows you to map to a new page without having to notify the user.

If we set the URL mapping, then any user in the URL bar input homepage.aspx, the call is originalhome.aspx.

Deep concept:

Let's see how to implement it.

This can be implemented in the configuration section.

Grammar:

<urlmappings enabled= "[True|false]" >
<add url= "String"
Mappedurl= "String"/>
</urlMappings>

If you want to use URL mapping, you must set the Enabled property to True. Each add element contains an original URL and a mapping URL. Yes, the concept is simple! If we have configured URL mappings for the above scenario, the elements in the config file are displayed as follows:

<urlmappings enabled= "true" >
<add url= "~/homepage.aspx" mappedurl= "~/originalhome.aspx"/>
</urlMappings>

Once we have modified or added elements as above in the Web.config file of the project, any user attempting to access Homepage.aspx will invoke the Originalhome.aspx page because of the URL mapping. Interestingly, the homepage.aspx is still displayed only in the URL bar. So despite the thought of internal call/execution originalhome.aspx, the user still sees hopepage.aspx in the URL bar.

Some advantages:

1. If your customer signs a link to a page, but you have to delete the page and change to another page, then use URL mapping you can solve this business problem without letting the customer know the page changes.

2. If there is a large and complex URL, but do not want to give it to the user, then you can tell the simple URL, and the simple URL itself to map to the original URL.

3. This method can be used to facilitate the processing of menu controls. The best example is the ASP.net site.

4. This also involves security (the user cannot see the real page name in the URL bar, which is also a kind of encryption!) )。

I hope you like this new feature.

Yes, I know, now your question is, now that ASP.net 2.0 is not available, how to take advantage of this new feature. Here's a workaround. Stev A brief explanation in his blog.

You can see it in http://weblogs.asp.net/ssmith/archive/2003/11/06/36191.aspx. His explanation is very simple, and according to your actual case, you can add functionality to it.

Now you can use this technique, and when ASP.net 2.0 is available, you can take advantage of the new features.


Related Article

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.