zoukankan      html  css  js  c++  java
  • IIRF重写在asp.net4.0+IIS6中部分失败的解决方案

    最近公司开始了一个新项目,使用的是asp.net mvc3、asp.net4.0、iis6。因为在iis6中不能支持无扩展名的路径。所以想到了使用Url重写。

        思路是这样的,在iis中添加.mvc的扩展名映射到C:WINDOWSMicrosoft.NETFrameworkv4.0.30319/aspnet_isapi.dll,这样就可以使用/home.mvc/index这样的路径,然后使用url重写

        RewriteRule ^/home/index/$ /home.mvc/index/ [I,L,U]

        这样就解决了以上的问题。但是在实践中一直显示404错误。

        原因如下:

        ASP.NET 4.0在安装的时候,会在IIS6注册一个ISAPI Filter,叫做”aspnet_filter.dll”,ISAPI Filter会先于ISAPI处理程序前执行,它会在所有的的无后缀的URL后面加一串字符“/eurl.axd/GUID”, 同时ASP.NET 4.0还会在IIS默认添加一个请求映射规则“*.axd”,映射到aspnet_isapi.dll。此时,所有的无后缀URL加上“/eurl.axd/GUID”后都会变成带.axd后缀,这样就匹配*.axd的映射规则进行ASP.NET的处理通道。在进入ASP.NET通道后,ASP.NET处理程序会删除掉“/eurl.axd/GUID”,让它还原到无后缀的原始情况,并且不会对后续的请求处理带来任何影响。此时,所有的无后缀请求,就进入了ASP.NET的处理通道中,在默认情况下,ASP.NET4.0的全局的web.config中配置了DefaultHttpHandler来接收无后缀的URL请求,但是我们也可以随意更换默认处理程序(比如ASP.NET MVC处理程序)来处理无后缀的URL请求。

       ASP.NET 4.0在IIS6原生支持没有后缀名的URL请求

       

        解决方法:移除aspnet_filter.dll

    http://www.asp.net/learn/whitepapers/aspnet4/breaking-changes#0.1__Toc256770153

       

    If it is not practical to remap the Web site to ASP.NET 2.0 or to change the location of a virtual directory, explicitly disable extensionless URL processing in ASP.NET 4. Use the following procedure:

    1. In the Windows registry, open the following node:

    HKEY_LOCAL_MACHINESOFTWAREMicrosoftASP.NET4.0.30319.0

    1. Create a new DWORD value named EnableExtensionlessUrls.
    2. Set EnableExtensionlessUrls to 0. This disables extensionless URL behavior.
    3. Save the registry value and close the registry editor.
    4. Run the iisreset command-line tool, which causes IIS to read the new registry value.
  • 相关阅读:
    Mac上搭建Hadoop环境(3) — Hive下载及安装
    Mac上搭建Hadoop环境(2) — Hadoop下载及安装
    Mac上搭建Hadoop环境(1) — 虚拟机的安装及SSH免密设置
    Mac上ssh localhost免密失败该如何解决
    Java8 Lambda 之 Collection Stream
    Java 集合Collection——初学者参考,高手慎入(未完待续)
    Java注解Annotation(一)
    ubuntu下安装和破解navicat的方法
    java I/O流类概述
    List元素为泛型时的注意事项
  • 原文地址:https://www.cnblogs.com/zhanghai/p/4461158.html
Copyright © 2011-2022 走看看