Reputation: 2752
Where does .net log authorization errors, or does it? I am not seeing anything in the event viewer, or anywhere but I am not sure if I need to turn something on or what.
I am using the using Microsoft.Owin.Security.Jwt UseJwtBearerAuthentication like so:
app.UseJwtBearerAuthentication(new JwtBearerAuthenticationOptions
{
TokenValidationParameters = tvps,
IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[]
{
new OpenIdConnectCachingSecurityTokenProvider("https://mydomain" + "/.well-known/openid-configuration")
}
});
And I have the Authorize attribute on a controller action. The jwt token is being passed and is valid so this SHOULD pass authorization but it is always failing, and I can't figure out how to debug.
Thanks!
Upvotes: 1
Views: 396
Reputation: 2752
I imported NLog
In the configuration method of my StarUp Class I added
app.UseNLog((eventType) => LogLevel.Trace);
it started logging the errors to my Nlog File
Upvotes: 0
Reputation: 345
You could apply a global exception handler which should capture the exception you are looking for, along with any other uncaught exceptions from your application. Create a new filter similar to the following and add it to the HttpFilterCollection during startup
public class CustomErrorAttribute : ExceptionFilterAttribute
{
/// <summary>
/// Override of the OnException method
/// </summary>
/// <param name="filterContext">The FilterContext object</param>
public override void OnException(HttpActionExecutedContext filterContext)
{
// access exception through "filterContext.Exception"
}
}
Upvotes: 1