http://www.cnblogs.com/artech/p/authentication-filter.html
我在这篇文章里面看到的,找遍了MVC4和MVC5都没看到,国外GOOGLE也没看到相关介绍,这个是一个神马玩意啊?请问一下命名空间是什么?
1: [Authenticate] 2: public class HomeController : Controller 3: { 4: public void Index() 5: { 6: Response.Write(string.Format("Controller.User: {0}<br/>", this.User.Identity.Name)); 7: Response.Write(string.Format("HttpContext.User: {0}<br/>", this.ControllerContext.HttpContext.User.Identity.Name)); 8: Response.Write(string.Format("Thread.CurrentPrincipal: {0}", Thread.CurrentPrincipal.Identity.Name)); 9: } 10: }
拼错了吧
[Authorize]
namespace System.Web.Mvc { /// <summary> /// 指定对控制器或操作方法的访问只限于满足授权要求的用户。 /// </summary> [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class AuthorizeAttribute : FilterAttribute, IAuthorizationFilter { .................
哎,现在的人怎么这么浮躁呢,都不看上下文的,他下面不是自定义了这个特性吗?
Authenticate 是一个正确的单词,没拼错
@Cherbim: 好吧,我开始没弄懂,麻烦您了