其实所谓的伪静态页面,就是指的URL重写,在ASP.NET中实现非常简单
首先你要在你的项目里引用两个DLL:
ActionlessForm.dll
URLRewriter.dll
真正实现重写的是 URLRewriter.dll 但是如果你要实现分页,那么必须使用这个ActionlessForm .dll
首先在web.config里写
< section name ="RewriterConfig" type ="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections >
<httpModules >
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</ httpModules>
<!-- 下面是配置重写URL规则 -->
< RewriterConfig>
< Rules>
< RewriterRule>
< LookFor> ~/Products/Jurisdiction_(/w{3})/.aspx</ LookFor>
< SendTo> ~/En/Jurisdiction.aspx?jurid=$1</ SendTo>
</ RewriterRule>
< RewriterRule>
< LookFor> ~/Articles/(/d{1,})/.aspx</ LookFor> <!-- 这个是被代替后的文件名,使用到正则表达式 -->
< SendTo> <![CDATA[~/En/Article_view.aspx?article_id=$1 ]]></ SendTo> <!-- 这个是要给代替的网页,一般是带有问号后面带参数的网页 -->
</ RewriterRule>
< RewriterRule>
< LookFor> ~/Articles/(/d{1,})_(/d{1,})/.aspx</ LookFor>
< SendTo> <![CDATA[~/En/Article_view.aspx?article_id=$1&page=$2 ]]></ SendTo>
</ RewriterRule>
</ Rules>
</ RewriterConfig>
这样比如上面的网址http://localhost/En/Article_View.aspx?article_id=9就可以用http://localhost/Articles/9.aspx来代替,当然,你代替后的扩展名可以用任何iis能解释的扩展名,如果你喜欢用htm做扩展名,那么在配置转发规则上面配置为htm为扩展名的,同样有些文章可能很长,往往我们会把一个文章分成几页,那么根据上面的配置,我们如果想访问http://localhost/En/Article_View.aspx?article_id=9&page=3我们就可以用http://localhost/Articles/9_3.aspx来代替,这样当搜索引擎来抓起你的网页的时候,就会收录你这些网址下去,别人搜索到你网页的时候,就可以从这些地址链接过来。
然后这样操作:
右键点我的电脑-->管理-->展开'服务和应用程序'-->internet信息服务-->找到你共享的目录-->右键点击属性 -->点击'配置'-->
映射下面 -->找到.aspx的可执行文件路径 复制路径-->粘贴路径-->扩展名为".html"-->然后把检查文件是否存在的勾去掉 这样就可以了
文章出处:http://hi.baidu.com/taoqi598/blog/item/2a11853b9de33fe215cecb8e.html