伪静态web.config配置步骤
网络编程 2021-07-04 22:40www.168986.cn编程入门
web.config是asp.一个重要的配置文件,本文将介绍如何利用web.config配置伪静态,步骤很详细,需要了解的朋友可以参考下
代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--第一步注册url重写模块放到webconfig的最上部-->
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<!--第二步添加重写规则-->
<RewriterConfig>
<!--先制定全部重写规则内容-->
<Rules>
<!--制定每个单独页面的规则-->
<RewriterRule>
<!--原始请求地址-->
<SendTo><![CDATA[~/news.aspx?id=$1&pid=$2]]></SendTo>
<!--重写后的地址-->
<LookFor>~/news/(.[0-9]*)/(.[\d]*)\.html</LookFor>
</RewriterRule>
<RewriterRule>
<!--原始请求地址-->
<SendTo><![CDATA[~/product.aspx?pid=$1]]></SendTo>
<!--重写后的地址-->
<LookFor>~/product/(.[\d]*)\.zangdalei</LookFor>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<pilation debug="false" targetFramework="4.0">
<!--第四部url重写防止真实的页面也被重写如果网站中真实存在页面,需要添加编译指令不编译真实的html文件-->
<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</pilation>
<!--第三部url重写 将用户的请求页面交给相应的处理程序,注意请求的后缀名格式-->
<httpHandlers>
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.zangdalei" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="asphtml" path="*.html" verb="GET,POST" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\asp_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
<add name="aspzangdalei" path="*.zangdalei" verb="GET,POST" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\asp_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
</handlers>
<defaultDocument>
<files>
<clear />
<add value="default.aspx" />
<add value="default.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
上一篇:C#各种集合操作的性能总结
下一篇:ASP.NE网站发布注意事项简析
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程