2012-02-05 12 views
0

ASP.Net MVC Webアプリケーションを作成し、Ninjectバージョン2.2.1.4とNinject.MVC3バージョン2.2.2.0をインストールするためにNuGetを使用しました。このアプリケーションはフォーム認証を使用します。System.Web.Mvc.AuthorizeAttributeがNinjectDependencyResolverと連携しない

protected void Application_Start() 
{ 
    AreaRegistration.RegisterAllAreas(); 

    RegisterGlobalFilters(GlobalFilters.Filters); 
    RegisterRoutes(RouteTable.Routes); 

    var kernel = new StandardKernel(); 
    // binding code goes here... 

    // Remove this dependency resolver and Authorisation will work... 
    DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); 
} 

そして、私のコントローラでの私の行動の1:

[Authorize(Roles = "Admin")] 
public ActionResult About() 
{ 
    return View(); 
} 

そして私は

は、これは私のApplication_StartのGlobal.asaxのメソッドです...認証が動作するようになって問題が生じています私のweb.configのauthenitcationセクション:

<authentication mode="Forms"> 
    <forms loginUrl="~/Account/LogOn" timeout="2880" /> 
</authentication> 

問題は、ユーザーは、LogOnにリダイレクトされるのではなく、About(情報)ビューに先んじて行きます。 Application_Startから「DependencyResolver.SetResolver ...」行を削除すると、NinjectDependencyResolverに問題があることがわかります。許可されていないユーザーはリダイレクトされます。

私はあなたの助けに感謝します。

よろしく、フィル・

答えて

関連する問題