WebActivator PreApplicationStartMethod exception handling

301 views Asked by At

How do I display a custom error page if some specific exception occurred in application initialization:

[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?
        }
    }
 }

I can put a custom errors section for all 500 errors, but I need a custom page for a specific scenario. Is it possible?

0

There are 0 answers