Tonight, when I moved the last demo to the end of the setup, I found that CSS could not be referenced. I thought about it for more than half a day and found that it was a user. aspx is rewritten to user/user by me. when aspx occurs, the directory reference problem occurs. The solution is to add more When referencing CSS ".. /", after solving this problem, another problem is found. The validatacode is referenced on the page. aspx verification code page, because it conforms to the regular expression, so this is also rewritten (only after 10 minutes of study), although validatacode does not appear in the address bar ., but it is overwritten. it also proves one thing. during rewriting, the address in the address bar is not only overwritten, but also the URL referenced in the URL is rewritten (of course, the regular expression is simply written "*\. in the case of aspx "), if there is no frame page in the page to reference another page or the page is very small, you can use the IF (* = validatacode) Return method without rewriting, of course, * the content can be obtained only by writing a few codes. The specific solution is to modify the regular expression as needed!
The final code in my configuration is as follows:
String suffixurl, lasturl, newurl = string. Empty, userid = string. empty;
Lasturl = request. rawurl;
If (lasturl. substring (0, 8). tolower () = "/cqspace") // deletes the root directory name
{
Suffixurl = lasturl. substring (9). tolower ();
}
Else
{
Suffixurl = lasturl. substring (1). tolower ();
}
If (suffixurl. tolower () = "default. aspx ")
{
Return;
}
Else
{
RegEx myreg = new RegEx (@ "(^ \ W + \ D *) \. aspx $ ");
If (myreg. ismatch (suffixurl ))
{
If (suffixurl. lastindexof ('/')>-1) return; // when a level-2 directory exists
Int lenght = suffixurl. lastindexof ('.');
Userid = suffixurl. substring (0, lenght );
If (userid. tolower () = "validatecode") return; // Verification Code
Newurl = "~ /User. aspx? Userid = "+ userid;
Httpcontext. Current. rewritepath (newurl );
}
}