2014-01-12 24 views
4

登錄頁面我使用OWIN與Facebook進行身份驗證每個:http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on重定向到與OWIN

我希望能夠當用戶嘗試,而他們是未經驗證的訪問頁面重定向到一個特定的登錄頁面。

現在,我用[Authorize]裝飾一個動作時,從IIS收到一個401錯誤。

如果我使用窗體身份驗證,我會在這我的web.config:

<authentication> 
    <forms loginUrl="~/Account/Login" timeout="2880" />  
</authentication> 

是否有類似的東西我可以做OWIN,或者我需要創建一個自定義屬性的授權?

回答

4

可以配置,當你配置的cookie認證登錄頁面:

 app.UseCookieAuthentication(new CookieAuthenticationOptions { 
      AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
      LoginPath = new PathString("/Account/Login"),