Asp.net mvc 2 当我在IIS7.5中将FormsAuthentication添加到ASP.NET MVC2站点时,我得到HTTP 403.14错误

Asp.net mvc 2 当我在IIS7.5中将FormsAuthentication添加到ASP.NET MVC2站点时,我得到HTTP 403.14错误,asp.net-mvc-2,forms-authentication,url-routing,iis-7.5,Asp.net Mvc 2,Forms Authentication,Url Routing,Iis 7.5,我已经编写了一个自定义表单身份验证模块,当我将其添加到MVC2应用程序的web.config中并在IIS7.5下运行时,会出现HTTP 403.14错误。如果我试图导航到任何路由URL,那么我只会得到一个404错误。恼人的是,我用卡西尼号做了所有的测试,一点问题也没有。我已经应用了所有类似问题的所有修复,但没有任何效果。问题似乎是我的模块注册的Mvc路由停止工作。显然,它似乎暗示了我的模块,但为什么它一直在使用内置的Web服务器工作呢?以下是my web.config的System.x部分:

我已经编写了一个自定义表单身份验证模块,当我将其添加到MVC2应用程序的web.config中并在IIS7.5下运行时,会出现HTTP 403.14错误。如果我试图导航到任何路由URL,那么我只会得到一个404错误。恼人的是,我用卡西尼号做了所有的测试,一点问题也没有。我已经应用了所有类似问题的所有修复,但没有任何效果。问题似乎是我的模块注册的Mvc路由停止工作。显然,它似乎暗示了我的模块,但为什么它一直在使用内置的Web服务器工作呢?以下是my web.config的System.x部分:

  <system.web>
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="Ewdev.Gatekeeper.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=02ca582b160d0e09" />
            </assemblies>
    </compilation>
    <authentication mode="Forms">
      <forms defaultUrl="/" loginUrl="/Authentication/Login" enableCrossAppRedirects="true" name=".GKAUTH" path="/" requireSSL="false" timeout="1440" />
    </authentication>
        <membership defaultProvider="GatekeeperMembershipProvider" userIsOnlineTimeWindow="120">
      <providers>
        <clear />
        <add name="GatekeeperMembershipProvider" type="Ewdev.Security.MembershipProviders.GatekeeperMembershipProvider, Ewdev.Gatekeeper.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=02ca582b160d0e09" connectionStringName="Ewdev Database" minRequiredPasswordLength="7" minRequiredAlphabeticCharacters="3" minRequiredAlphabeticCaseChanges="1" minRequiredNumericCharacters="1" minRequiredNonAlphanumericCharacters="0" passwordWordsPolicy="true" passwordHistoryPolicy="13" enablePasswordRetrieval="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" minRequiredUserNameLength="6" minRequiredUserNameAlphabeticCharacters="1" minRequiredUserNameNumericCharacters="0" userNameEnableNonAlphanumeric="true" userNameWordsPolicy="true" />
      </providers>
    </membership>
    <customErrors mode="On" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Linq" />
        <add namespace="System.Collections.Generic" />
      </namespaces>
    </pages>
        <trace enabled="false" mostRecent="true" />
  </system.web>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="true" />
        <modules runAllManagedModulesForAllRequests="true">
            <remove name="FormsAuthentication" />
            <add name="FormsAuthentication" type="Ewdev.Security.GatekeeperFormsAuthenticationModule" preCondition="" />
        </modules>
        <handlers>
            <remove name="MvcHttpHandler" />
            <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler" />
            <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </handlers>
    </system.webServer>

这一切都运行在我的Windows7x64桌面上,带有VS2010、.NET4和Mvc2。我已在IIS中安装/注册了ASP.NET4。我怀疑您可能想知道模块中有什么,但是源代码相当长,所以我不知道哪个位是相关的。它按照与内置API规范相同的API规范构建,但除了在需要时重定向到登录页面外,对请求Url没有其他更改,并且在尝试显示对所有人开放的主页时出现错误。我已经读到,这可能与非aspx资源有关,例如脚本、css、图像文件,因为模块被设置为应用于所有资源类型?其他的想法是在Url路由模块之后调用我的模块,但我不相信这一点,第三,Global.asax可能不会被调用?我在我的第三天撕我的头发在这一个,主要是因为我估计1小时安装到IIS的网站。。。啊


如果我能找出bit IIS不喜欢的地方,我将非常感激能得到的任何帮助,并且非常乐意重写我的模块。卡西尼喜欢它:-(

我的猜测是您将MVHttpHandler设置错误。路径属性应该是*而不是*.mvc

我的猜测是您将MVHttpHandler设置错误。路径属性应该是*而不是*.mvc

我终于有了一个解决方案!但它非常模糊,我花了一周的时间来猜测

我确信这个问题与路由有关,许多人说你需要添加HTTP重定向特殊角色。我已经添加了HTTP错误静态内容压缩。最终的解决方案是重新安装这3个角色les!这表明在IIS世界中安装东西的顺序非常重要,因为我在安装MVC2(通过VS2010安装)之前已经设置了IIS7.5,尽管我已经多次进行了其他修复(ASP.NET 4.0 x86和x64的aspnet_regiis-I),但这并没有解决路由问题。我是不是先安装了VS2010(包括MVC2)然后安装IIS7.5,我想我不会有问题。除此之外,信不信由你,完全重新安装IIS7.5并没有解决问题,因为我几天前已经尝试过了。因此,为了回顾并包括任何其他必要的配置,以下是重要的修复:

  • 确保您已运行aspnet_regiis-i 对于框架/v4…和 框架64/v4

  • 确保您已允许使用ASP.NET v4 对于IIS中的32位和64位 (通过IIS管理器,单击 树中的服务器条目并转到 ISAPI和CGI限制)

  • 确保您有HTTP错误HTTP 重定向通用HTTP IIS专用 角色和静态内容压缩 性能IIS特殊角色 已安装。如果已安装 取消安装并重新安装,这是 是什么最终解决了这个问题 我

  • 请注意:IIS7也是如此,因为我必须在生产Windows 2008 server上执行完全相同的程序。我希望这有助于其他人快速解决问题。我现在可能会失去我的合同,因为我因为这个问题远远落后

    我原来的web.config中有几个不必要的条目,因为我正在尝试人们提出的任何解决方案,所以下面是我当前正在使用的web.config的System.x部分

      <system.web>
        <compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="Ewdev.Gatekeeper.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=02ca582b160d0e09" />
          </assemblies>
        </compilation>
        <authentication mode="Forms">
          <forms defaultUrl="/" loginUrl="/Authentication/Login" enableCrossAppRedirects="true" name=".GKAUTH" path="/" requireSSL="false" timeout="1440" />
        </authentication>
        <membership defaultProvider="GatekeeperMembershipProvider" userIsOnlineTimeWindow="120">
          <providers>
            <clear />
            <add name="GatekeeperMembershipProvider" type="Ewdev.Security.MembershipProviders.GatekeeperMembershipProvider, Ewdev.Gatekeeper.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=02ca582b160d0e09" connectionStringName="Ewdev Database" minRequiredPasswordLength="7" minRequiredAlphabeticCharacters="3" minRequiredAlphabeticCaseChanges="1" minRequiredNumericCharacters="1" minRequiredNonAlphanumericCharacters="0" passwordWordsPolicy="true" passwordHistoryPolicy="13" enablePasswordRetrieval="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" minRequiredUserNameLength="6" minRequiredUserNameAlphabeticCharacters="1" minRequiredUserNameNumericCharacters="0" userNameEnableNonAlphanumeric="true" userNameWordsPolicy="true" />
          </providers>
        </membership>
        <customErrors mode="On" />
        <pages>
          <namespaces>
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Linq" />
            <add namespace="System.Collections.Generic" />
          </namespaces>
        </pages>
        <trace enabled="false" mostRecent="true" />
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="true" />
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="FormsAuthentication" />
          <add name="FormsAuthentication" type="Ewdev.Security.GatekeeperFormsAuthenticationModule" />
        </modules>
      </system.webServer>
    

    我终于有了一个解决方案!但它太模糊了,花了我整整一周的时间去猜测

    我确信这个问题与路由有关,许多人说你需要添加HTTP重定向特殊角色。我已经添加了HTTP错误静态内容压缩。最终的解决方案是重新安装这3个角色les!这表明在IIS世界中安装东西的顺序非常重要,因为我在安装MVC2(通过VS2010安装)之前已经设置了IIS7.5,尽管我已经多次进行了其他修复(ASP.NET 4.0 x86和x64的aspnet_regiis-I),但这并没有解决路由问题。我是不是先安装了VS2010(包括MVC2)然后安装IIS7.5,我想我不会有这个问题。除此之外,信不信由你,一个