AIis7Bottom pureHtmlThe page request source for many reasons:
- Multiple independent domain names are bound to oneWebsite
- Domain Name vendor not supportedURL forwarding
- Automatically after the domain name is enteredRedirectTo the primary domain name, such:
- InputWww.ccc.netLaterRedirectToWww.aaa.com
- InputWww.ddd.cnLaterRedirectToWww.aaa.com
So I tried to make an HTML handler.
Steps:
-
- Set the target website'sApplication poolThe mode isIntegrate
-
- Write. NET 2.0OfHttphandlerTo process requests(Here is*. HtmlFile request)
- Public Class Urlverify: ihttphandler
{
Public Bool Isreusable
{
Get { Return True ;}
}
Const String Mainhostname = " Www.aaa.com " ;
Public Void Processrequest (httpcontext context)
{
If (Context. Request. url. Host. tolower ()! = Mainhostname)
{
String Url = generatemainsiteurl (context. Request. url. absoluteuri, context. Request. rawurl );
Context. response. Redirect (URL, True );
}
Else
{
Context. response. writefile (context. Request. physicalpath );
}
}
Public String Generatemainsiteurl ( String Fullurl, String Virtualpath)
{
String Url = fullurl;
String Preurl = " HTTP " ;
If (URL. substring ( 0 , 5 ). Tolower () = " HTTPS " )
Preurl = " HTTPS " ;
Virtualpath = virtualpath. trimstart ('/');
Url =String. Format ("{0}: // {1}/{2}", Preurl, mainhostname, virtualpath );
ReturnURL;
}
}
-
- After the compiledDLLFiles are stored on the target websiteBinDirectory
- OpenIis7,Find the target website and double-clickHandler MappingsIcon
-
- In the upper-right cornerClick Add managed HandlerLink
-
-
- OK
Confused:
The above components are used. Net2.0Compiled, I use. Net4.0I tried it, but I always reported an error. I don't know what's going on. I hope my experienced brother will tell me.