是[授权]属性为ASP.NET MVC控制器只为会员供应商? [英] Is the [Authorize] attribute for ASP.NET MVC controllers only for Membership Providers?

查看:189
本文介绍了是[授权]属性为ASP.NET MVC控制器只为会员供应商?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否与ASP.NET MVC的控制器只与网站的功能已实施的MembershipProvider使用的[授权]属性?

Does the [Authorize] attribute used with ASP.NET MVC controllers only function with sites that have implemented a MembershipProvider?

推荐答案

简短的回答是否定的。它只是检查是否存在一个IPrincipal的,怎么说到达那里是你的。

Short answer is no. It just checks that there is a IPrincipal, how that gets there is up to you.

我有我使用会员提供的,而不是,一旦我验证的用户只需要调用FormsAuthentication.SetAuthCookie方法我自己的登录逻辑。一旦你这样做,你就可以使用[授权]属性。

I have my own login logic that I use instead of the Membership provider, once I've authenticated a user I just call the FormsAuthentication.SetAuthCookie method. Once you've done that you can then use the [Authenticate] attribute.

这篇关于是[授权]属性为ASP.NET MVC控制器只为会员供应商?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆