认证 – WebApi ActionFilterAttribute,HttpActionContext访问用户名(IPr
发布时间:2020-12-27 18:58:37 所属栏目: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-mvc – 在EditorFor for child对象中使用时,MVC无法
- ASP.NET TextBox LostFocus事件
- 在ASP.NET中使用querystring的最佳做法?
- ASP.NET:隐藏gridview中的列
- asp.net+js 实现无刷新上传解析csv文件的代码
- Asp.net配合easyui实现返回json数据实例
- Asp.NET控制文件上传的大小方法(超简单)
- asp.net-mvc – Asp.Net MVC CSLA DDD可能
- asp.net-mvc-4 – 在哪里可以找到WebMatrix.WebData.WebSec
- asp.net-mvc – UpdateModel前缀 – ASP.NET MVC
