日期:2014-05-18  浏览次数:20424 次

网站的伪静态如何实现?
asp.net的网站,要做成伪静态的网站。
下载了URLRewriter.dll,在BIN里引用了。
然后在web.config里进行了设置。
在IIS里也添加了扩展名.html

网页里的连接还是原来的<a href="aaa.aspx?id=1">查看</a>
网站运行后,点连接地址栏还是aspx的。
是不是我网页里也需要改啊。



------解决方案--------------------
第一步,请从此下载此组件。解压,把UrlRewriter.dll copy到你的项目 bin 目录下。

第二步,在Web.config中加入:

<?xml version="1.0" encoding="gb2312" ?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>

第二步,加入重写的规则节点:
如:
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/Sell/(.[0-9]*)\.html</LookFor>
<SendTo>~/Search/Search_Sell.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Sell/Search_Sell\.aspx</LookFor>
<SendTo>~/Search/Search_Sell.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Buy/(.[0-9]*)\.html</LookFor>
<SendTo>~/Search/Search_Buy.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Buys/(.[0-9]*)\.html</LookFor>
<SendTo>~/Buys/Show.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>


------解决方案--------------------
可以下载相关组件实现