【发布时间】:2017-02-09 19:58:09
【问题描述】:
我正在使用 asp.net web api 项目。我添加了ExceptionFilterAttribute。
public class ExceptionFilter : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
//How to get user id.
}
}
在我的项目中,我启用了匿名身份验证。我正在尝试使用 HttpContext.Current.User.Identity.Name; 获取 userId,但该值始终为空字符串。我是否需要包含任何 nugget 包才能获取 userId?
有时,我可能会通过移动客户端收到请求,在这种情况下,我如何检查 userId 以及如何确定请求是否来自移动客户端?
【问题讨论】:
标签: c# asp.net asp.net-web-api asp.net-web-api2