我有一个启用了ASP.NET身份验证的Windows应用程序,我想使用一个基本的拦截器来处理未经身份验证的请求,但完全跳过了这一步,因为Windows身份验证机制在进入拦截器之前会阻止请求。
您是否知道是否有一种方法可以绕过此标准行为,而不阻塞进入拦截器管道的请求?
提前感谢!

发布于 2021-04-09 22:49:56
使用中间件并在UseAuthorization之前声明它
public class YourMiddleware
{
private readonly RequestDelegate _next;
public YourMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
Console.WriteLine("Before");
// Here you can decide if you want the next step of the pipeline or not, usually you want
await _next(context);
}
}app.UseMiddleware<YourMiddleware>();
app.UseAuthorization();https://stackoverflow.com/questions/67023115
复制相似问题