.Net Intelligencia.UrlRewriter 重定向参数中文支持配置方法

在使用.Net 官方 Url重定向组件时,发现若原地址包含中文,如:http://localhost/首页.html 重定向为:http://localhost/index.aspx?id=首页  时,接收的中文参数为乱码,使用各种方法解决无果,发现一博友的解决方法有效:

https://www.cnblogs.com/simoncai/p/5711700.html

使用环境为:iis7+.net4.0。

解决完成后,重新配置IIS又花费了些时间,记录一下全部Web.config内容:

<?xml version="1.0" encoding="UTF-8"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <configSections>
    <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
  </configSections>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpModules>
      <add type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter" />
    </httpModules>
  </system.web>

  <system.webServer>
    <!--解决集成通道无法使用问题-->
    <validation validateIntegratedModeConfiguration="false" />
    <defaultDocument>
      <files>
        <add value="index.aspx" />
      </files>
    </defaultDocument>
    <handlers>
    <!--添加html脚本映射--> <add name="rewriter" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" /> </handlers> </system.webServer> <rewriter> <!--重写规则--> <rewrite url="^/(\d+).aspx$" to="~/index.aspx?id=$1" processing="stop" /> <rewrite url="^/(.+).html$" to="~/index.aspx?id=$1"/> </rewriter> </configuration>

 

posted @ 2018-10-26 21:20  Sunky  阅读(350)  评论(0编辑  收藏  举报