Simple use of URL rewriting for Microsoft urlrewriter. dll

Source: Internet
Author: User

Add reference urlrewriter. DLL to the bin directory of the project, and download the package/files/jaylong/ from Microsoft.

1. Configure nodes under <configsections> of the <configuration> node in the web. config file

<! -- Configure the rewrite rule node -->
<Section name = "rewriterconfig" type = "urlrewriter. config. rewriterconfigserializersectionhandler, urlrewriter"/>

2. write rewrite rules in the <configuration> node range class

<! -- Rewrite Rules -->
<Lookfor> ~ /Web/New/(. [0-9] *) \. aspx </lookfor>
<Sendto> ~ /Web/New. aspx? Id = $1 </sendto>
<Lookfor> ~ /Index.html </lookfor>
<Sendto> ~ /Default. aspx </sendto>
<Lookfor> ~ /Show _ ([0-9] * cmd.html </lookfor>
<Sendto> ~ /Show. aspx? Id = $1 </sendto>

3. Configure

 <Add verb = "*" Path = "*. aspx" type = "urlrewriter. rewriterfactoryhandler, urlrewriter"/>
<Add verb = "*" Path = "*. html" type = "urlrewriter. rewriterfactoryhandler, urlrewriter"/> <! -- If this node is not added, HTML pages cannot be targeted. -->

4. Enter index.html in the browser and access the default. aspx page.

Export show_2.html actually accesses show. aspx? Page with ID = 2

Download all source code:/files/jaylong/

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: 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.