Web Api 2 HttpContext or HttpActionContext

What is the difference between the following two ways to access a principle through an AuthorizeAttribute implementation?

Using HttpContext :

 protected override bool IsAuthorized(HttpActionContext actionContext) { return HttpContext.Current.User.IsInRole("DemoRole"); } 

Using HttpActionContext :

 protected override bool IsAuthorized(HttpActionContext actionContext) { return actionContext.RequestContext.Principal.IsInRole("DemoRole"); } 
+6
source share

Source: https://habr.com/ru/post/981762/


All Articles