zbx888
New member
- Joined
- Aug 17, 2023
- Messages
- 2
- Programming Experience
- 5-10
I have intranet.net core razor app with default exception handling setting as follows: if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); app.UseHsts(); }
I have one custom middleware to deal with Windows Authentication with Identity membership and check the user id application user. If not the application user, app throws one exception as follows:
if (user != null)
{
await signInManager.SignInAsync(user, true);
context.User = await signInManager.CreateUserPrincipalAsync(user);
_logger.LogInformation($"User with id {user.Id}, name {user.UserName} successfully signed in");
// Workaround
context.Items["IntranetUser"] = user;
}
else
{
_logger.LogInformation($"User cannot be found in identity store.");
throw new System.InvalidOperationException($"user not found.");
}
In production, the exception is never catched instead of 500 error. How to solve this issue? Thanks!
I have one custom middleware to deal with Windows Authentication with Identity membership and check the user id application user. If not the application user, app throws one exception as follows:
if (user != null)
{
await signInManager.SignInAsync(user, true);
context.User = await signInManager.CreateUserPrincipalAsync(user);
_logger.LogInformation($"User with id {user.Id}, name {user.UserName} successfully signed in");
// Workaround
context.Items["IntranetUser"] = user;
}
else
{
_logger.LogInformation($"User cannot be found in identity store.");
throw new System.InvalidOperationException($"user not found.");
}
In production, the exception is never catched instead of 500 error. How to solve this issue? Thanks!