0
我正在使用asp.net web api项目。我添加了一个ExceptionFilterAttribute
。在asp.net web api中的ExceptionFilterAttribute中获取userId信息
public class ExceptionFilter : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
//How to get user id.
}
}
在我的项目中,我启用了匿名身份验证。我正在尝试使用HttpContext.Current.User.Identity.Name;
来获取userId,但该值始终是一个空字符串。我是否需要包含任何金块包以获取userId?
有时,我可能通过移动客户端获得请求,那么,如何检查userId以及如何从移动客户端获取请求?