QuanCheng Shangcheng multi-user edition has the need to access the form of second-level domain names in terms of ACCESS format. Quancheng found through data study that most of the solutions provided in the network are based on the re-targeting URL address, it is equivalent to forwarding, and cannot implement real second-level domain name access; or rewrite the URL address to implement second-level domain name access, which indeed achieves real second-level domain name access, but there is a fatal defect, this greatly reduces the program running performance when the URL address is overwritten by a program. So far, can there be a third solution that is more effective in solving access to second-level domain names without affecting program performance. We have made the third original solution, so we can use it to develop it. We will discuss and practice with our technical friends !! Please try your best to improve a perfect second-level domain name ACCESS format for. Net !!!!
The code for implementing the second-level domain name Access Solution of Quancheng mall multi-user edition is as follows:
String STR = system. Web. httpcontext. Current. Request. url. Host. tostring ();
String aburl = system. Web. httpcontext. Current. Request. url. absoluteuri. tostring ();
String strr = system. Web. httpcontext. Current. Request. querystring. tostring ();
String strurl = system. Web. httpcontext. Current. Request. url. pathandquery. tostring ();
String [] strlist = Str. Split (New char [] {'.'});
String TB = strlist [0]. tostring ();
If (strlist. length> = 3)
{
If (Tb. tolower () = "www ")
{
If (strr. tolower (). Contains ("SJID "))
{
String [] strl = system. Text. regularexpressions. RegEx. Split (strr, "&", system. Text. regularexpressions. regexoptions. ignorecase );
Int SID = convert. toint32 (system. text. regularexpressions. regEx. split (strl [0], "=", system. text. regularexpressions. regexoptions. ignorecase) [1]);
If (New configdb (). getissdo () = "1 ")
{
If (Tb. tolower () = "192" | TB. tolower () = "127 ")
{
Response. Redirect ("http: //" + STR + "/userweb/" + Sy. getmb (SID) + strurl );
}
Else
{
Response. redirect ("http: //" + Str. replace ("www", Sy. getsjuserbyid (SID )). replace ("CP1", Sy. getsjuserbyid (SID) + strurl );
}
}
Else
{
If (Tb. tolower () = "192" | TB. tolower () = "127 ")
{
Response. Redirect ("http: //" + STR + "/userweb/" + Sy. getmb (SID) + strurl );
}
Else
{
Response. Redirect ("" + weburl + "/userweb/" + Sy. getmb (SID) + strurl );
}
}
}
}
Else
{
If (! Sy. supplymembernameexistt (strlist [0]. tostring ()))
{
System. Web. httpcontext. Current. response. Write (getym ("" + weburl + "/error. aspx "));
Response. End ();
Return;
}
Else
{
Sqldatareader SDR = Sy. getadmindetailsbyname (strlist [0]. tostring ());
String MB = string. empty;
String cid = string. empty;
While (SDR. Read ())
{
MB = SDR ["MB"]. tostring ();
Cid = SDR ["ID"]. tostring ();
}
SDR. Close ();
If (! Strurl. tolower (). Contains ("? "))
{
If (strurl. tolower (). Contains ("html "))
{
If (strurl. tolower (). Contains ("default "))
{
Response. Redirect (weburl );
Response. End ();
Return;
}
Else
{
System. Web. httpcontext. Current. response. Write (getym ("" + weburl + "/" + strurl + ""));
Response. End ();
Return;
}
}
Else
{
System. Web. httpcontext. Current. response. Write (getym ("" + weburl + "/userweb/" + MB + "/index. aspx? SJID = "+ CID + ""));
Response. End ();
Return;
}
}
Else
{
System. Web. httpcontext. Current. response. Write (getym ("" + weburl + "/userweb/" + MB + "/" + strurl + ""));
Response. End ();
Return;
}
}
}
}