CoreSupport
asked on
how to handle problems in application_start in global.asax
Hi all,
Heres a quirky one.
In short:
Is there any way to catch errors in the Application_Start method of global.asax and display a custom error message to the user based on the problem?
In a bit more detail:
In the Application_Start method in my Global.asax file, I ve a call to the database to get some config settings. The connection details are pulled from web.config which is fine.
I also have a custom error page setup. If an error bubbles up Application_Error of global.asax catchs it and the Server.Transfer() method is called.
i.e.
void Application_Error(object sender, EventArgs e)
{
Server.Transfer("~/CustomE rrorPage.a spx");
}
This normally works fine, but I noticed there that it doesnt work when any exceptions are created during Application_Start (e.g. a database connection error). The Server.Transfer() method gives me a "error executing child request".
Basically, it looks like i cant use Server.Transfer() for errors in application start. So is there any way to catch an error in application start and display it gracefully. Or is it just best to leave the full stack trace showing so the installers can see whats happened?
Thanks
d
Heres a quirky one.
In short:
Is there any way to catch errors in the Application_Start method of global.asax and display a custom error message to the user based on the problem?
In a bit more detail:
In the Application_Start method in my Global.asax file, I ve a call to the database to get some config settings. The connection details are pulled from web.config which is fine.
I also have a custom error page setup. If an error bubbles up Application_Error of global.asax catchs it and the Server.Transfer() method is called.
i.e.
void Application_Error(object sender, EventArgs e)
{
Server.Transfer("~/CustomE
}
This normally works fine, but I noticed there that it doesnt work when any exceptions are created during Application_Start (e.g. a database connection error). The Server.Transfer() method gives me a "error executing child request".
Basically, it looks like i cant use Server.Transfer() for errors in application start. So is there any way to catch an error in application start and display it gracefully. Or is it just best to leave the full stack trace showing so the installers can see whats happened?
Thanks
d
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, I tried Response.Redirect and saw it wouldnt work.
Ok thats what I thought, that I would have to use the default error screen.
Just thought I was missing something.
Thanks
D