我们如何处理IIS上的ASP.NET MVC应用程序的异常

时间:2022-01-21 04:12:25

Below is how I am handling exception in my ASP.NET MVC application.

下面是我在ASP.NET MVC应用程序中处理异常的方法。

  • Created a Base Controller and overridden OnException method to catch all ASP.NET MVC pipeline errors.
  • 创建了一个基本控制器并重写了OnException方法以捕获所有ASP.NET MVC管道错误。
  • To capture errors which are beyond ASP.NET MVC pipeline. i.e. 404 - I am using CustomError tag in web.config.
  • 捕获超出ASP.NET MVC管道的错误。即404 - 我在web.config中使用CustomError标记。

Now, suppose my application is down and not running, then I still want my users to display some error page and want it to configure on IIS level. Could anyone please explain me how we can achieve that and I would also like to know the priority. I mean I want that priority of IIS error should be least.

现在,假设我的应用程序已关闭而未运行,那么我仍然希望我的用户显示一些错误页面并希望它在IIS级别进行配置。有谁能请解释我如何实现这一点,我也想知道优先事项。我的意思是我希望IIS错误的优先级应该是最小的。

1 个解决方案

#1


0  

When your app is under maintenance, you need to provide a HttpRedirect to an empty page, which says "Please try after X time, due to upgrade". Your main app should remain there. When any user comes to your main app, it will immediately redirect to the empty app instead of using your app's code. Here's how to setup redirect on IIS.

当您的应用程序处于维护状态时,您需要向空白页面提供HttpRedirect,其中显示“由于升级,请在X时间后尝试”。你的主应用应该留在那里。当任何用户访问您的主应用时,它会立即重定向到空应用,而不是使用您应用的代码。以下是如何在IIS上设置重定向。

https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httpredirect/

https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httpredirect/

#1


0  

When your app is under maintenance, you need to provide a HttpRedirect to an empty page, which says "Please try after X time, due to upgrade". Your main app should remain there. When any user comes to your main app, it will immediately redirect to the empty app instead of using your app's code. Here's how to setup redirect on IIS.

当您的应用程序处于维护状态时,您需要向空白页面提供HttpRedirect,其中显示“由于升级,请在X时间后尝试”。你的主应用应该留在那里。当任何用户访问您的主应用时,它会立即重定向到空应用,而不是使用您应用的代码。以下是如何在IIS上设置重定向。

https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httpredirect/

https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httpredirect/