2012-10-23 25 views
1

無論如何,你可以說在MVC中使用OAuth,並使用屬性在驗證過程中啓用對控制器的訪問。 可以說我有使用Attrubutes調用控制器的OAuth安全性?

public class myownController 
{ 
    [LoginRequired] 
    public ActionResult Index(){ 
    //this can be accesed only of the user is logged in. 
    } 
} 

回答

2

如果您使用ASP.Net MVC 4本應建在使用默認AuthorizeAttribute。如果不是,我建議手動將標準Forms Authentication機制與您選擇的OAuth提供程序集成。由於您使用ASP.Net MVC 4看一看ASP.NET MVC Authentication - Customizing Authentication and Authorization The Right Way

,我會強烈建議閱讀SimpleMembership, Membership Providers, Universal Providers and the new ASP.NET 4.5 Web Forms and ASP.NET MVC 4 templates。 MVC 4中存在重大變化,使整個Membership和OAuth變得非常簡單。

+0

感謝您的回答。我應該挖掘它...我使用MVC 4 – Mihai

+0

更新了具體的MVC 4內容。 –

相關問題