Protected void application_beginrequest (Object sender, eventargs E)
{
String strrawurl = httpcontext. Current. Request. rawurl;
String strnewurl;
//************************************** **************************************** *************
// Rewrite the category address
If (RegEx. ismatch (strrawurl, @ "post. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "post. aspx", @ "showclass. aspx \? Classid = 14 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "resources. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "resources. aspx", @ "showclass. aspx \? Classid = 13 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "mobileapplications. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "mobileapplications. aspx", @ "showclass. aspx \? Classid = 12 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "server. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "server. aspx", @ "showclass. aspx \? Classid = 11 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "database. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "database. aspx", @ "showclass. aspx \? Classid = 10 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "WebServices. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "WebServices. aspx", @ "showclass. aspx \? Classid = 7 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "windowsapplications. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "windowsapplications. aspx", @ "showclass. aspx \? Classid = 6 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "webapplications. aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "webapplications. aspx", @ "showclass. aspx \? Classid = 2 ");
Httpcontext. Current. rewritepath (strnewurl );
}
//************************************** **************************************** ****************
// Display detailsArticleAddress Rewriting
Else if (RegEx. ismatch (strrawurl, @ "(\ D +). aspx", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "(\ D +). aspx", @ "showpost. aspx \? Id = $1 ");
Httpcontext. Current. rewritepath (strnewurl );
}
Else if (RegEx. ismatch (strrawurl, @ "showpost. aspx \? Id = (\ D +) ", regexoptions. ignorecase ))
{
Strnewurl = RegEx. Replace (strrawurl, @ "showpost. aspx \? Id = (\ D +) ", @" $1. aspx ");
Httpcontext. Current. response. Redirect (strnewurl );
}
}
The preceding code is rewritten. Next is the inverse operation.
For more information, see http: // ithero.net.