其实所谓的伪静态页面,就是指的URL重写,在ASP.NET中实现非常简单,下面是个简单的流程,高手就不用看了.
首先你要在你的项目里引用两个DLL:
ActionlessForm.dll
URLRewriter.dll
真正实现重写的是 URLRewriter.dll 但是如果你要实现分页,那么必须使用这个ActionlessForm .dll
首先在web.config里写
<?
xml version="1.0" encoding="utf-8"
?>
< configuration >
< configSections >
< section name ="RewriterConfig" type ="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</ configSections >
< RewriterConfig >
< Rules >
<!-- Rules for Blog Content Displayer -->
< RewriterRule >
< LookFor > ~/read(.[0-9]*)/.html </ LookFor >
< SendTo > ~/WebForm1.aspx?UserID=$1 < ndTo >
</ RewriterRule >
</ Rules >
</ RewriterConfig >
< appSettings >
< add key ="dbType" value ="sql" ></ add >
< add key ="data" value ="server=.;uid=sa;pwd=sa;database=pubs;Connect Timeout=30;" ></ add >
</ appSettings >
< system .web >
< httpHandlers >
< add verb ="*" path ="*.aspx" type ="URLRewriter.RewriterFactoryHandler, URLRewriter" />
< add verb ="*" path ="*.html" type ="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</ httpHandlers >
< configuration >
< configSections >
< section name ="RewriterConfig" type ="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</ configSections >
< RewriterConfig >
< Rules >
<!-- Rules for Blog Content Displayer -->
< RewriterRule >
< LookFor > ~/read(.[0-9]*)/.html </ LookFor >
< SendTo > ~/WebForm1.aspx?UserID=$1 < ndTo >
</ RewriterRule >
</ Rules >
</ RewriterConfig >
< appSettings >
< add key ="dbType" value ="sql" ></ add >
< add key ="data" value ="server=.;uid=sa;pwd=sa;database=pubs;Connect Timeout=30;" ></ add >
</ appSettings >
< system .web >
< httpHandlers >
< add verb ="*" path ="*.aspx" type ="URLRewriter.RewriterFactoryHandler, URLRewriter" />
< add verb ="*" path ="*.html" type ="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</ httpHandlers >
这样好像还不行,那是因为在IIS里面无法解析.html后缀名(具体我也不知道怎么叫...)
然后这样操作:
右键点我的电脑-->管理-->展开'服务和应用程序'-->internet信息服务-->找到你共享的目录-->右键点击属性 -->点击'配置'-->
映射下面 -->找到.aspx的可执行文件路径 复制路径-->粘贴路径-->扩展名为".html"-->然后把检查文件是否存在的勾去掉 这样就可以了