我将一些Web API服务添加到现有的MVC应用程序中。 我有一个模型绑定器为我的MVC控制器获取用户对象存储在一个CustomIdentity。 我正在为我的Web API操作重现这一点。
在MVC控制器或其粘合剂我可以使用
controllerContext.HttpContext.User.IdentityApiController没有HttpContext对象。 有没有从Web API访问IIdentity对象?
I'm adding some Web API services to an existing MVC application. I have a model binder for my MVC controllers to get the user object stored in a CustomIdentity. I'm trying to reproduce this for my Web API actions.
In the MVC Controller or its binders I can use
controllerContext.HttpContext.User.IdentityThe ApiController doesn't have the HttpContext object. Is there anyway to access the IIdentity object from the Web API?
最满意答案
他们在ASP.NET MVC 4 RC中删除了GetUserPrincipal。 但是,似乎ApiController属性User已经取代了这个: http : //msdn.microsoft.com/en-us/library/system.web.http.apicontroller.user
They removed GetUserPrincipal in ASP.NET MVC 4 RC. However it seems the ApiController property User has replaced this: http://msdn.microsoft.com/en-us/library/system.web.http.apicontroller.user
更多推荐
发布评论