认证 – WebApi ActionFilterAttribute,HttpActionContext访问用户名(IPr
发布时间:2020-12-05 05:13:13 所属栏目:asp.Net 来源:互联网
导读:这个问题在这里已经有一个答案: Can I access IIdentity from Web API4个 我需要在我的操作过滤器中访问当前登录的用户.身份由DelegatingHandler进一步设定执行链. 我可以使用HttpContext.Current.User访问当前
|
这个问题在这里已经有一个答案:>
Can I access IIdentity from Web API4个
我可以使用HttpContext.Current.User访问当前的IPrincipal. 有没有其他方法可以在ActionFilter中访问用户的身份?或者,如果您不打算运行自托管应用程序,可以使用HttpContext吗? 解决方法我忽略了明显的.我没有意识到ControllerContext中有一个Controller属性.var username = ((ApiController)context.ControllerContext.Controller).User.Identity.Name; (编辑:南阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net中使用repeater和PageDataSource搭配实现分页代码
- asp.net-mvc – 应用程序服务层作为静态类
- 在IIS / ASP.Net中的.NET 1.1应用程序中创建.NET 3.0子应用
- asp.net-mvc – 使用asp.net mvc 2功能与火花浏览引擎
- asp.net-mvc – 在ASP.NET MVC中获取当前操作/控制器的自定
- asp.net-mvc – ASP.NET MVC 3 Treeview
- asp.net-mvc – 如果用户在int字段中放入非数字字符串,则自
- 如何从经典ASP输出Excel * .xls文件
- ASP.NET(C#)应用程序配置文件app.config/web.config的增、删
- .net – 加密ApplicationServices ConnectionString
