By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,405 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,405 IT Pros & Developers. It's quick & easy.

Server.Transfer in Application_Error()

P: n/a
Hi
My code
Global.asax

Application_Start()
{
// Code
// There is possibility of Exception in above Code
}

Applicaton_Error()
{
// in the Redirect Page i m displying the Error Message
//from Server.GetLastError();
Server.Transfer("CapError.aspx");
}

My problem:-
For the "First" time when the application is loaded,
there is possible exception.
After encountring Exception the Asp.net is executing
Application_Erorr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redirect as well)
I didnt touch WebConfig file.

Could some one please help me out.

Thanks
Kris
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
By the time Application_Error runs, the page has already finished
processing, so there is no context in which to transfer the user.

You should handle Page_Error on your page. If all your pages transfer to
the same page in case of error, I would recommend having a base class that
all your pages inherit from that handles this event.
"Kris Meher" <me*****@hotmail.com> wrote in message
news:02****************************@phx.gbl...
Hi
My code
Global.asax

Application_Start()
{
// Code
// There is possibility of Exception in above Code
}

Applicaton_Error()
{
// in the Redirect Page i m displying the Error Message
//from Server.GetLastError();
Server.Transfer("CapError.aspx");
}

My problem:-
For the "First" time when the application is loaded,
there is possible exception.
After encountring Exception the Asp.net is executing
Application_Erorr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redirect as well)
I didnt touch WebConfig file.

Could some one please help me out.

Thanks
Kris

Nov 18 '05 #2

P: n/a
Thanks a lot..
All my Pages are inherited from a base class.
I tired the below code in base class.

public BasePage()
{

// Page.Init += new
System.EventHandler(this.Page_Error);
}
// public void Page_Error(Object sender,
EventArgs e)
// {
// // Implementation here
// Server.Transfer("caperror.aspx");
// }

Basically for the first time when it is loading the app
it is encountring the exception(it is not executing the
complete appliction_start() function).
After that it goes to Application_Error(), there it
doesnt know any thing about the context of Application...

Still it is not working after adding the event page_error
to base class.
Is there any way i can achieve this :(
Thanks
Kris


-----Original Message-----
By the time Application_Error runs, the page has already finishedprocessing, so there is no context in which to transfer the user.
You should handle Page_Error on your page. If all your pages transfer tothe same page in case of error, I would recommend having a base class thatall your pages inherit from that handles this event.
"Kris Meher" <me*****@hotmail.com> wrote in message
news:02****************************@phx.gbl...
Hi
My code
Global.asax

Application_Start()
{
// Code
// There is possibility of Exception in above Code
}

Applicaton_Error()
{
// in the Redirect Page i m displying the Error Message //from Server.GetLastError();
Server.Transfer("CapError.aspx");
}

My problem:-
For the "First" time when the application is loaded,
there is possible exception.
After encountring Exception the Asp.net is executing
Application_Erorr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redirect as well)
I didnt touch WebConfig file.

Could some one please help me out.

Thanks
Kris

.

Nov 18 '05 #3

P: n/a
the correct syntax is:

public BasePage : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
this.Error += new System.Eventhandler(this.Page_Error);
}

public void Page_Error(Object sender, EventArgs e)
{
// do generic error handling here
}
}
<an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Thanks a lot..
All my Pages are inherited from a base class.
I tired the below code in base class.

public BasePage()
{

// Page.Init += new
System.EventHandler(this.Page_Error);
}
// public void Page_Error(Object sender,
EventArgs e)
// {
// // Implementation here
// Server.Transfer("caperror.aspx");
// }

Basically for the first time when it is loading the app
it is encountring the exception(it is not executing the
complete appliction_start() function).
After that it goes to Application_Error(), there it
doesnt know any thing about the context of Application...

Still it is not working after adding the event page_error
to base class.
Is there any way i can achieve this :(
Thanks
Kris


-----Original Message-----
By the time Application_Error runs, the page has already

finished
processing, so there is no context in which to transfer

the user.

You should handle Page_Error on your page. If all your

pages transfer to
the same page in case of error, I would recommend having

a base class that
all your pages inherit from that handles this event.
"Kris Meher" <me*****@hotmail.com> wrote in message
news:02****************************@phx.gbl...
Hi
My code
Global.asax

Application_Start()
{
// Code
// There is possibility of Exception in above Code
}

Applicaton_Error()
{
// in the Redirect Page i m displying the Error Message //from Server.GetLastError();
Server.Transfer("CapError.aspx");
}

My problem:-
For the "First" time when the application is loaded,
there is possible exception.
After encountring Exception the Asp.net is executing
Application_Erorr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redirect as well)
I didnt touch WebConfig file.

Could some one please help me out.

Thanks
Kris

.

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.