473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Server.Transfer in Application_Error()

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
3 6846
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Shaun Wilde | last post by:
I am trying to handle a 404 errors and redirect them to the correct page based on criteria I was hoping to catch the error in the global error handler and forward via Server.Transfer to the...
0
by: Greg | last post by:
Why would I get this suddenly now that I am running in VS 2005: System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object."...
6
by: jeff29_b | last post by:
I am trying to remove dependence on the frameworks custom error mechanisms to get a site to work with google sitemaps, because they framework does a redirect 302 to the errorpage. Instead I am...
0
by: Larry | last post by:
Here's an interesting one. This happens only in the asp.net server that is launched from VS.Net 2005. In IIS it does not occur. We placed a server.transfer call in our global.asax's...
1
by: David Herbst | last post by:
VS 2005 / .NET 2.0 Windows 2000 Server sp4 (on development as well as testing server) Using Web Deployment Project to build assemblies for testing and production servers. I added a Global.asax...
1
by: David Thielen | last post by:
Hi; If an exception is thrown in the global.asax Application_Start then calling HttpApplication.Server.Transfer throws an exception. How can I tell from the HttpApplication object if it is ok...
6
by: n# | last post by:
A Basic Question in ASP.NEt 1.1 In Page_Load Event I am doing a Server.Transfer. But it throws an error on the browser windows showing "Server Application Not Found" Pls help me
0
by: Michael | last post by:
Hi I have a problem related to global.asax and the Server.Mappath-Method. I collect all unhandled errors in the Application_Error in Global.asax. According to the type of error I...
5
by: vishalgupta | last post by:
i have void Application_Error(object sender, EventArgs e) { Server.Transfer("default.aspx"); } in global.asax now when i use any state bags like Session = "new";...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.