日期:2014-05-16  浏览次数:20812 次

ASP.NET 伪静态 静态页 访问不了 方法

本站基于asp.net+UrlRewriter来实现网站伪静态,实现伪静态有一些好处,比如对于搜索引擎更好收录页面,还有一个好处就是隐藏了 真实地址的参数,所以有独立服务器的朋友,配置IIS实现伪静态功能,挺不错的哦,至于ASP.NET如何实现伪静态,可以看下本人写的这篇文章:http://www.xueit.com/html/2009-02/21_494_00.html ,现在有一个问题来了,我配置伪静态成功后,而真正的静态文件(html)却访问不了,有点苦脑,不过最终还是找到了解决方案。请看下面的解决方法:

第1步、打开Web.config配置文件

第2步、在如下节点:

<compilation debug="false">
</compilation>

加入内容,最终内容变成如下:

Code [http://www.xueit.com]
< compilation debug ="false" > < buildProviders > < add extension =".html" type ="System.Web.Compilation.PageBuildProvider" /> </ buildProviders > </ compilation >

之后继续再加入如下内容:

Code [http://www.xueit.com]
< httpHandlers > < add verb ="*" path ="*.html" type ="System.Web.UI.PageHandlerFactory" /> </ httpHandlers >

配置好以上内容,就可以实现asp.net的伪静态html内容与真正的静态文件html就可以访问了。

配置参考本站的web.config图:

?

?

?

?

?

?

?

?

?

============================================================================

?

?

配置.HTML伪静态后静态.html文件不能访问了,asp.net错误为“没有为扩展名“.html”注册的生成提供程序”加上以下红色区域节点就OK了

< compilation? defaultLanguage ="c#" ?debug ="true" >
????
<