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