您的位置:首页 > 编程语言 > ASP

再谈asp.net中.aspx如何映射成html静态网页的方法(URL重写)

2009-03-28 09:07 656 查看
一、首先在IIS中增加扩展名为.html的映射
.html
c:/windows/microsoft.net/framework/v2.0.50727/aspnet_isapi.dll

二、在WEB.CONFIG中增加
<!--url重写-->
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<!-- 分类显示-->
<RewriterRule>
<LookFor>~/Sort/(.[0-9]*)/.html</LookFor>
<SendTo>~/Sort/Ads_Detail.aspx?ADid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/ManageCenter/Add_Post_(.[0-9]*)_(.[0-9]*).html</LookFor>
<SendTo><![CDATA[~/ManageCenter/AdsPost_Add.aspx?f=$1&s=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/ManageCenter/Add_Post_Sucess.html</LookFor>
<SendTo><![CDATA[~/ManageCenter/AdsPost_Sucess.aspx?f=$1&s=$2]]></SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>

<!--url映射-->
<!--首页-->
<urlMappings enabled="true">
<add url="~/Default.html" mappedUrl="~/default.aspx" />
</urlMappings>
<!--
<httpHandlers>
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />

</httpHandlers>

<httpModules>
<add name="MagicAjax" type="MagicAjax.MagicAjaxModule, MagicAjax" />
</httpModules>
-->
三、编译站点,用IE浏览,大功告成。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: