WebActivator PreApplicationStartMethod异常处理

时间:2017-03-10 10:13:35

标签: asp.net .net error-handling custom-error-pages webactivator

如果应用程序初始化中发生某些特定异常,如何显示自定义错误页面:

[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(NinjectWebCommon), "Start")]
public static class NinjectWebCommon
{
    public static void Start()
    {
        try
        { 
             // init code
        }
        catch (MyInitializationException exception)
        {
             // HttpContext.Current is null here
             // Redirect to static html page
             // Maybe its possible to customize status code here?
        }
    }
 }

我可以为所有500个错误添加自定义错误部分,但我需要针对特定​​方案的自定义页面。有可能吗?

0 个答案:

没有答案