2012-09-06 81 views
2

我試圖使用一個基於Dominic Baier的優秀工作的一個自定義ClaimsAuthorizationManager,它在一個新的MVC4應用程序中仍然非常基於現成的Internet模板,我配置它似乎想要授權所有內容並忽略[AllowAnonymous]屬性。AllowAnonymous屬性在MVC4中被ClaimsAuthorizationManager忽略

看着堆棧跟蹤似乎是ExtensionlessUrlHandler-Integrated-4.0觸發AuthorizationManager代碼。

IIS7.5 Detailed Error

我覺得這是無論是配置的問題,我的web.config(見下文),或者我需要在我AuthorizationManager不是當時執行檢查一些額外的邏輯。

我在這裏的完整性是控制器的片段:

[AllowAnonymous] 
public class HomeController : Controller 
{ 
    [AllowAnonymous] 
    public ActionResult Index() 
    { 
     ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; 

     return View(); 
    } 

system.web節:

<system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    <authorization> 
    <!--<deny users="?" />--> 
    </authorization> 
    <authentication mode="Forms"> 
    <forms loginUrl="~/Account/Login" timeout="2880" /> 
    </authentication> 
    <roleManager enabled="true" defaultProvider="simple"> 
    <providers> 
     <clear /> 
     <add name="simple" type="WebMatrix.WebData.SimpleRoleProvider,WebMatrix.WebData" /> 
    </providers> 
</roleManager> 
<membership defaultProvider="simple"> 
    <providers> 
     <clear /> 
     <add name="simple" type="WebMatrix.WebData.SimpleMembershipProvider,WebMatrix.WebData" /> 
    </providers> 
</membership> 
<pages> 
    <namespaces> 
    <add namespace="System.Web.Helpers" /> 
    <add namespace="System.Web.Mvc" /> 
    <add namespace="System.Web.Mvc.Ajax" /> 
    <add namespace="System.Web.Mvc.Html" /> 
    <add namespace="System.Web.Optimization" /> 
    <add namespace="System.Web.Routing" /> 
    <add namespace="System.Web.WebPages" /> 
    </namespaces> 
</pages> 
<httpModules> 
    <!--WIF 4.5 modules --> 
    <!--Not needed here for IIS >= 7 --> 
    <!--<add name="ClaimsAuthorizationModule" type="System.IdentityModel.Services.ClaimsAuthorizationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>--> 
</httpModules> 

的system.webServer部分:

<system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> 
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> 
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
    </handlers> 
    <modules runAllManagedModulesForAllRequests="false"> 
    <remove name="RoleManager" /> 
    <remove name="FormsAuthentication" /> 

    <!--WIF 4.5 modules --> 
    <add name="ClaimsAuthorizationModule" type="System.IdentityModel.Services.ClaimsAuthorizationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 
    <add name="ClaimsTransformationModule" type="HillIntl.MyLCM.Security.ClaimsTransformationHttpModule" /> 

    <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" /> 
</modules> 

身份模型部分:

<!--WIF 4.5 s.im section--> 

回答