认证 – WebApi ActionFilterAttribute,HttpActionContext访问用户名(IPr
发布时间:2020-12-05 04:11:09 所属栏目: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 – 使用MVC3剃刀的ASP.Net图表控件
- asp.net – 转发器控件中的单选按钮列表
- 如何在服务器端缓存ASP.NET自定义HttpHandler响应
- VS 2013 RC中缺少ASP.NET Web窗体脚手架功能
- asp.net-core – .net核心自定义身份验证中的User.Identity
- asp-classic – 如何使用Microsoft.XMLHTTP指定代理配置?
- asp.net – IControllerFactory’MyWebSite.WebUI.Infrastr
- asp.net – Web部署安装程序(MSI)中没有“IIS 7部署处理程序
- asp.net-mvc – 从ASP.NET Web API返回一些字段
- asp.net-mvc-3 – 依赖注入与多个类实现的接口
推荐文章
站长推荐
- asp.net-mvc-3 – Azure网站上的RavenDb – 访问
- asp.net-mvc-3 – 在MVC 3.0中重写Html.BeginFor
- ASP.NET 2.0和4.0似乎在Forms身份验证中以不同方
- asp.net – 查询字符串参数使我的应用程序面临风
- asp.net-mvc – SSL握手问题? (当时:网页挂起,
- Asp.Net Core中WebSocket绑定的方法详解
- ASP.NET网站攻击:如何回应?
- ASP.NET – 可以从服务器代码触发回发吗?
- asp.net – 渗透测试人员说.ASPXAUTH cookie是不
- asp.net-mvc-3 – 如何从ASP.NET MVC#输出中删除
热点阅读