Establish site navigation hierarchy in asp.net 2.0 (5)

Source: Internet
Author: User
Tags add define config net reference

URL mapping

The URL mapping attribute uses the configuration information stored in Web.config to remap the received request (remap) to a different URL. The remapping occurs before all other processing operations on the request. The following example shows the remapping of a page request, in which any file type can actually remap the request to a different URL.

To define a remapping URL

The configuration information for URL mappings is stored in web.config. Each element nested in the element defines a rule for the inbound URL that maps into the site. The URL property defines the exact (as-is) attribute of the URL that enters the site, and the URL mapping attribute attempts to match it. If a exact matching operation occurs, the Mappedurl property value is rewritten to the URL that enters the site. Note that this feature does not support more advanced rules (such as matching based on wildcard wildcards expressions expressions).

Example Web.config defines a mapping rule for a large number of URLs. The example used by the Web.sitemap file defines a large number of nodes with URL values that will be mapped. The result is a combination of URL mapping and site navigation that allows developers to define the navigation structure with a friendly URL and use URL mapping to write the request back to a different page to perform the actual process.

When you run the example, note how the menu and TreeView controls display navigation data based on the site structure defined in the Web.sitemap file. If you hover your mouse over a link in the TreeView control or the SiteMapPath control in the upper-right corner, the URL displayed in the status bar is a friendly URL link. When you click on any navigation link, the actual running page is default.aspx. However, navigation information in the menu, TreeView, and SiteMapPath controls is still reflected as a friendly URL structure.

You can also see the values returned by Request.path, request.querystring["category", and Request.rawurl at the bottom of the page. The value returned by Request.path and request.querystring["category" always reflects the result of remapping the URL into the site. However, the Request.rawurl value reflects the friendly URL before the remapping. When the site navigation feature attempts to match the URL information with the data contained in the sitemap file, it uses Request.rawurl. If the matching value is not found, XmlSiteMapProvider the Request.path as a substitute. In the example, all friendly URLs have entries in the Web.sitemap file, so controls that use site navigation always display and reference nodes based on friendly URLs.

The following is a reference fragment:
>






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.