In the Web development site, we often use pseudo-static, the advantage is to hide the real path, improve the security of the site, on the website and other display sites want to search engine friendly, improve search rankings, or when it comes to template development will use pseudo-static. The following is an explanation of the pseudo-static implementation method used in peacetime.
One, method one:
Using Urlrewriter.dll:http://download.microsoft.com/download/0/4/6/0463611e-a3f9-490d-a08c-877a83b797cf/msdnurlrewriting.msi
1 Add the URLRewriter.dll file reference in the startup file, and then add The code under the Config node
<configSections> <section name="rewriterconfig" type= " URLRewriter.Config.RewriterConfigSerializerSectionHandler, Urlrewriter"/> </ Sectiongroup> </configSections>
2 Add code under the system.web node
<compilation>
<buildProviders>
<add extension= ". html" type= "System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
</compilation>
"*"Path="*.html"Type="System.Web.UI.PageHandlerFactory"/> "Urlrewriter.modulerewriter, Urlrewriter"Name="Modulerewriter"/> 3 Add a rewrite URL code (regular expression) under the Configuration node
<RewriterConfig> <Rules> <RewriterRule> <lookfor><![ cdata[~/shop/(\w+)?] ></LookFor> <sendto><![ cdata[~/vshop/wechat/order/index.aspx?uid=$1]]></sendto> </RewriterRule> < Rewriterrule> <lookfor><![ cdata[~/tupian/(\d+)/.html]]></lookfor> <sendto><![ cdata[~/web/admin/other/$1.ashx]]></sendto> </RewriterRule> </Rules> </RewriterConfig>
Second, method two
Starting with the. net3.5 version, the System.Web.Routing is available, and the program can write its own pseudo-static method
Add a ReWriteUrl.cs file with the following code:
PublicClassRewriteurl:iroutehandler {public string urlrote { get; private set;} Public Rewriteurl (string surlrote) {urlrote = surlrote;} public IHttpHandler Gethttphandler (RequestContext requestcontext) { return Buildmanager.createinstancefromvirtualpath (Urlrote, typeof (IHttpHandler)) as IHttpHandler;}}
In the Application_Start function under the Global.asax.cs file
protected void Application_Start (object sender, EventArgs e) { new Route (" xxxx.html"new Rewriteurl ("~/xxxx.ashx")); //Address rewriting }
. NET technology Exchange QQ Group: 320128737
Methods of pseudo-static implementation of C #