如果应用程序初始化中发生某些特定异常,如何显示自定义错误页面:
[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个错误添加自定义错误部分,但我需要针对特定方案的自定义页面。有可能吗?