Implementation method of two-level domain name implementation by Universal parsing and pseudo-static under ASP.

Source: Internet
Author: User

In net Microsoft has left us an interface that lets us do whatever we want.

First, we can get a picture of the life cycle of the. Net.

As you can see, for each different user's request, the server creates a new HttpContext instance until the request is finished and the server destroys the instance. Ihttpcontext is an externally exposed interface of HttpContext, which contains 2 methods: Dispose () and init (HttpApplication context), We can achieve ihttpcontext so as to achieve HttpContext.
Key code:

Copy CodeThe code is as follows:
HttpApplication app = (HttpApplication) sender;
HttpContext context = App. Context;
String url = context. Request.Url.AbsoluteUri; Full URL
string turl = URL. Split ('. ') [0];
String surl = Turl. ToLower (). Replace ("http://", "");
StringBuilder strb = new StringBuilder ();
Strb. Append (URL);
Strb. Append (sURL);


App. Context.rewritepath (Path, String. Empty, Strb. ToString (). Split ('? ') [1]);
Under configuration in Web. config:
Add the following code in the <system.web>.
<add type= "Common.urlrewriter" name= "Common"/>
When you finally set up IIS, remember to set the IIS header to empty.
You can make it work.

Implementation method of two-level domain name implementation by Universal parsing and pseudo-static under ASP.

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.