无论如何我尝试在控制器层中抛出异常时,此捕获线不会触发。
连接链接Global exception handling in OWIN middleware
public class GlobalExceptionMiddleware : OwinMiddleware
{
public GlobalExceptionMiddleware(OwinMiddleware next) : base(next)
{ }
public override async Task Invoke(IOwinContext context)
{
try
{
await Next.Invoke(context);
}
catch (Exception ex)
{
}
}
}
我以这种方式抛出异常:
public class MyController
{
public async Task<MyRestModel> Get(int id)
{
throw new Exception();
我做错了什么?