473,785 Members | 2,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.Transfer in Application_Err or()

Hi
My code
Global.asax

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

Applicaton_Erro r()
{
// in the Redirect Page i m displying the Error Message
//from Server.GetLastE rror();
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_Ero rr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redire ct as well)
I didnt touch WebConfig file.

Could some one please help me out.

Thanks
Kris
Nov 18 '05 #1
3 6869
By the time Application_Err or 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*****@hotmai l.com> wrote in message
news:02******** *************** *****@phx.gbl.. .
Hi
My code
Global.asax

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

Applicaton_Erro r()
{
// in the Redirect Page i m displying the Error Message
//from Server.GetLastE rror();
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_Ero rr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redire ct 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.EventHan dler(this.Page_ Error);
}
// public void Page_Error(Obje ct 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_star t() function).
After that it goes to Application_Err or(), 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_Err or 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*****@hotmai l.com> wrote in message
news:02******* *************** ******@phx.gbl. ..
Hi
My code
Global.asax

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

Applicaton_Erro r()
{
// in the Redirect Page i m displying the Error Message //from Server.GetLastE rror();
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_Ero rr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redire ct 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.P age
{
protected override void OnInit(EventArg s e)
{
this.Error += new System.Eventhan dler(this.Page_ Error);
}

public void Page_Error(Obje ct sender, EventArgs e)
{
// do generic error handling here
}
}
<an*******@disc ussions.microso ft.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.EventHan dler(this.Page_ Error);
}
// public void Page_Error(Obje ct 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_star t() function).
After that it goes to Application_Err or(), 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_Err or 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*****@hotmai l.com> wrote in message
news:02******* *************** ******@phx.gbl. ..
Hi
My code
Global.asax

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

Applicaton_Erro r()
{
// in the Redirect Page i m displying the Error Message //from Server.GetLastE rror();
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_Ero rr().
But the page is "not" Transfering to CapError.aspx.
(I tried with Response.Redire ct 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
1841
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 correct page such that it would appear to be the page requested. ow this does work to a fashion but it seems that I don't have access to the session state when I undergo a Server.Transfer from the Application_Error. Can anyone suggest another way...
0
1156
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." Source="System.Web" StackTrace: at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) at VPM.Global.Application_Error(Object sender, EventArgs e) in C:\Inetpub\wwwroot\VPM\App_Code\Global.asax.vb:line 104
6
2057
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 doing server.transfers from the applicaiton_error event. This seems to work fine except for in the case of 404 errors. Is there any way to do a server.transfer from application_error on a 404 error?
0
996
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 Application_Error. When an unhandled exception occurs, this works fine. However, we are seeing that on every page request (under asp.net development server debug mode), that after the ProcessRequest for the desired page, the Application_Error fires as...
1
1858
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 file to my web site so I could implement a Application_Error() handler. The handler works fine on my development web server but when I deploy it to the testing web server it doesn't execute. Instead I get the detailed ASP.NET error page or my...
1
2192
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 to call Transfer? -- thanks - dave david_at_windward_dot_net
6
2191
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
1268
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 redirect/transfer the user to the correct error page. DataException --~/DBError.aspx
5
2615
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"; whenever the user clicks on link to a page that does not exist on the server, Application_Error() executes but Server.Transfer does not and it shows that the page cannot be found and does not transfer to default.aspx.
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10324
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.