I have an ASP.NET Web Api 2.0 project with token authentication and all that is done mainly after this article:
Token-based authentication using ASP.NET Web API 2, Owin and Identity , a bit of technology
But I'm afraid to understand what exactly this line of code in my Startup.cs does:
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
This does not cause Web Api to add the Access-Control-Allow-Origin header to my API responses, in other words, it does not allow Cors in my Web Api (still trying to figure out how to do this, by the way), It doesn't even add it to the bearer token authentication server response. I must have this code for my OAuthAuthorizationServerProvider:
public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
to enable Cors in marker provider endpoint responses.
So what is Microsoft.Owin.Cors middleware? Because everywhere I read about Web Api 2.0 and Cors this line of code
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
:
source share