带url重写的web.config

本文档展示了如何配置web.config文件实现URL重写。通过使用UrlRewritingNet库,可以将URL重定向到实际的处理程序,如`list.aspx`、`content.aspx`等,以实现更友好的URL结构。配置包括对`system.web`、`httpModules`和`httpHandlers`部分的设置,以及使用`<urlrewritingnet>`节定义重写规则。
摘要由CSDN通过智能技术生成

<?xml version="1.0"?>

<configuration>

<configSections>

<section name="urlrewritingnet" restartOnExternalChanges="true" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>

<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

</sectionGroup>

</sectionGroup>

</sectionGroup>

</configSections>

<appSettings>

<!--设置system目录的相对路径,请相对于web.config文件所在的目录(设置这个属性以后,该虚拟目录下所有级别目录页面的控件调用都不用单独设置systemfolder属性,方便项目的整体调用)-->

<add key="systemfolder" value="system_dntb/"/>

<!--设置皮肤目录的相对路径,请相对于system目录(设置这个属性以后,该虚拟目录下所有级别目录页面的控件调用都不用单独设置skin属性,方便项目的整体调用)-->

<add key="skin" value="skin/xp/"/>

<!--<add key="ConnectionString" value="Data Source=taobaodaili.db.5343016.hostedresource.com;Initial Catalog=taobaodaili;User ID=taobaodaili;Password=Wyj5816778"/>-->

<!--<add key="ConnStr" value="Data Source=shop.188dl.com;Initial Catalog=taobaodaili;User ID=taobaodaili;Password=1"/>-->

<add key="DAL" value="Maticsoft.SQLServerDAL"/>

<add key="ConnectionString" value="Data Source=shop.188dl.com;Initial Catalog=taobaodaili;User ID=taobaodaili;Password=1"/>

<!--<add key="ForumPath" value="/UrlRewriter/"/>-->

</appSettings>

<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="default.aspx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">

<rewrites>

 

 

<add name="Rule3" virtualUrl="^~/list(.*)/([0-9]+)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/content.aspx?itemid=$2&amp;cateid=$1" ignoreCase="true"/>

<add name="Rule2" virtualUrl="^~/list(.*)/p(.*)$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/list.aspx?cateid=$1&amp;page=$2" ignoreCase="true"/>

<add name="Rule1" virtualUrl="^~/list([0-9]+)/$" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/list.aspx?cateid=$1" ignoreCase="true"/>

</rewrites>

</urlrewritingnet>

<connectionStrings/>

<system.web>

<!-- 

            设置 compilation debug="true" 可将调试符号插入

            已编译的页面中。但由于这会 

            影响性能,因此只在开发过程中将此值 

            设置为 true。

        -->

<compilation debug="true">

<assemblies>

<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

</assemblies>

</compilation>

<!--

            通过 <authentication> 节可以配置 ASP.NET 用来 

            识别进入用户的

            安全身份验证模式。 

        -->

<authentication mode="Windows"/>

<!--

            如果在执行请求的过程中出现未处理的错误,

            则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,

            开发人员通过该节可以配置

            要显示的 html 错误页

            以代替错误堆栈跟踪。

 

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

            <error statusCode="403" redirect="NoAccess.htm" />

            <error statusCode="404" redirect="FileNotFound.htm" />

        </customErrors>

        -->

<customErrors mode="Off"/>

 

<pages  validateRequest="false" enableViewStateMac="false">

<controls>

<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</controls>

</pages>

<httpHandlers>

<remove verb="*" path="*.asmx"/>

<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>

</httpHandlers>

<httpModules>

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<!--<add type="HttpModule" name="HttpModule"/>-->

<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>

</httpModules>

<httpRuntime maxRequestLength="2097151" executionTimeout="3600"/>

</system.web>

<system.codedom>

<compilers>

<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

<providerOption name="CompilerVersion" value="v3.5"/>

<providerOption name="WarnAsError" value="false"/>

</compiler>

</compilers>

</system.codedom>

<!-- 

        在 Internet 信息服务 7.0 下运行 ASP.NET AJAX 需要 system.webServer

        节。对早期版本的 IIS 来说则不需要此节。

    -->

<system.webServer>

<validation validateIntegratedModeConfiguration="false"/>

<modules>

<remove name="ScriptModule"/>

<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</modules>

<handlers>

<remove name="WebServiceHandlerFactory-Integrated"/>

<remove name="ScriptHandlerFactory"/>

<remove name="ScriptHandlerFactoryAppServices"/>

<remove name="ScriptResource"/>

<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</handlers>

</system.webServer>

<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<dependentAssembly>

<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>

<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>

<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

</dependentAssembly>

</assemblyBinding>

</runtime>

</configuration>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值