ASP.NET WEP.API 5.2.6: Authorize attribute access from within controller

I’ve created an empty MVC Web.Api project. It runs. I simply want to access the authorize (or my derivative of it) from within the web api method being called.

I’ve seen several options which seem to only apply to old versions of Web.API

Ignore the controller, it just has [AuthorizeBetter] on bits. In my AuthorizeBetterAttribute I have:

public override void OnAuthorization(HttpActionContext actionContext) { //actionContext.RequestContext. //actionContext.RequestContext. var c = actionContext.Request.GetConfiguration(); //c. base.OnAuthorization(actionContext); } 

All the commented out lines are simply examples of what is on the HttpActionContext. I don’t know where to find anything I might use.

In googled examples HttpActionContext is not used, i.e.:

public override void OnAuthorization(AuthorizationContext filterContext) { filterContext.HttpContext.Items["key"] = "Save it for later"; base.OnAuthorization(filterContext); } 

or another old one:

public class AuthorizeAuthorAttribute : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) 

So using the latest NON CORE version of WebApi, how do I convey data from the authorize attribute into my method?

submitted by /u/serentilla
[link] [comments]

Leave a Reply