无论如何,你可以说在MVC中使用OAuth并使用像验证过程中的属性来启用对控制器的访问。 让我说我有
public class myownController
{
[LoginRequired]
public ActionResult Index(){
//this can be accesed only of the user is logged in.
}
}
答案 0 :(得分:2)
如果您使用的是ASP.Net MVC 4,则应使用默认的AuthorizeAttribute内置。如果不是,我建议您手动将标准表单身份验证机制与您选择的OAuth提供程序集成。看看ASP.NET MVC Authentication - Customizing Authentication and Authorization The Right Way
由于您使用的是ASP.Net MVC 4,我强烈建议您阅读SimpleMembership, Membership Providers, Universal Providers and the new ASP.NET 4.5 Web Forms and ASP.NET MVC 4 templates。 MVC 4中有重大变化,使整个会员和OAuth变得非常简单。