本文主要是介绍再谈asp.net中.aspx如何映射成html静态网页的方法(URL重写),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、首先在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浏览,大功告成。 |
这篇关于再谈asp.net中.aspx如何映射成html静态网页的方法(URL重写)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!