473,467 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Application_Error not Transferrig to custom page

When a System.ArgumentOutOfRangeException is throw it gets caught in my Application_Error event. But I want it to be dealt with and then passed to a specific page. I dont want to use redirect becuase i want the Server info that gets picked up by Error.aspx page. Instead of transferring it displays the old yellow and white Server error page.
protected void Application_Error(Object sender, EventArgs e)
{
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog(); //Create a new EventLog object
myLog.Source = Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set the name of the Log
myLog.WriteEntry(_message, System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("Error.aspx"); <---does not transfer to my page here
}

<customErrors mode="RemoteOnly" />

thanx in advance

MattC
Nov 18 '05 #1
3 1566
Hi,

You can write an error message to the session. Then you have to do a response.Redirect.
When you load an errorPage, you can get this message from the Session.

bye

"MattC" <m@m.com> wrote in message news:Op**************@TK2MSFTNGP15.phx.gbl...
When a System.ArgumentOutOfRangeException is throw it gets caught in my Application_Error event. But I want it to be dealt with and then passed to a specific page. I dont want to use redirect becuase i want the Server info that gets picked up by Error.aspx page. Instead of transferring it displays the old yellow and white Server error page.
protected void Application_Error(Object sender, EventArgs e)
{
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog(); //Create a new EventLog object
myLog.Source = Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set the name of the Log
myLog.WriteEntry(_message, System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("Error.aspx"); <---does not transfer to my page here
}

<customErrors mode="RemoteOnly" />

thanx in advance

MattC
Nov 18 '05 #2
Yeah that is my solution if I cant resolve my current problem but shouldn't my current method work?
"Michael Tkachev" <m_*******@hotmail.com> wrote in message news:eN**************@TK2MSFTNGP12.phx.gbl...
Hi,

You can write an error message to the session. Then you have to do a response.Redirect.
When you load an errorPage, you can get this message from the Session.

bye

"MattC" <m@m.com> wrote in message news:Op**************@TK2MSFTNGP15.phx.gbl...
When a System.ArgumentOutOfRangeException is throw it gets caught in my Application_Error event. But I want it to be dealt with and then passed to a specific page. I dont want to use redirect becuase i want the Server info that gets picked up by Error.aspx page. Instead of transferring it displays the old yellow and white Server error page.
protected void Application_Error(Object sender, EventArgs e)
{
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog(); //Create a new EventLog object
myLog.Source = Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set the name of the Log
myLog.WriteEntry(_message, System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("Error.aspx"); <---does not transfer to my page here
}

<customErrors mode="RemoteOnly" />

thanx in advance

MattC
Nov 18 '05 #3
No, your current method will not work. You are not calling
Server.ClearError(). That means the framework will put out the generic
error page.

You must call Server.ClearError(), after obtaining a reference to
Server.GetLastError(), so you can redirect to another page.

If you are stuck on using Server.Transfer, you might want to look at
override the Page level OnError method.

HTH,

bill

"MattC" <m@m.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Yeah that is my solution if I cant resolve my current problem but shouldn't
my current method work?
"Michael Tkachev" <m_*******@hotmail.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
Hi,

You can write an error message to the session. Then you have to do a
response.Redirect.
When you load an errorPage, you can get this message from the Session.

bye

"MattC" <m@m.com> wrote in message
news:Op**************@TK2MSFTNGP15.phx.gbl...
When a System.ArgumentOutOfRangeException is throw it gets caught in my
Application_Error event. But I want it to be dealt with and then passed to
a specific page. I dont want to use redirect becuase i want the Server info
that gets picked up by Error.aspx page. Instead of transferring it displays
the old yellow and white Server error page.
protected void Application_Error(Object sender, EventArgs e)
{
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
//Create a new EventLog object
myLog.Source =
Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set
the name of the Log
myLog.WriteEntry(_message,
System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("Error.aspx"); <---does not transfer to my page here
}

<customErrors mode="RemoteOnly" />

thanx in advance

MattC
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Greg Burns | last post by:
I am trying to write a global custom error page. I thought I would jot down some of what I've learned so far... At first I just used the default customErrors section with a defaultRedirect tag,...
3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
4
by: Michael | last post by:
Using some example code I've found, I'm trying to do the custom error page thing. I have the following in global.asax.. Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Dim...
6
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error...
1
by: robertlair | last post by:
I am having issues with a production server with the GetLastError() method. Here is what I am doing: Application_Error on Global ASAX: Note: I am doing it this way (with ClearError) because...
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...
10
by: Nemisis | last post by:
Hi everyone, I am trying to create a custom error page, that the user gets shown when a error has occurred within my website. The code works perfectly, apart from when an invalid URL is typed...
19
by: =?Utf-8?B?anZjb2FjaDIz?= | last post by:
I've got a global.aspx file that works in my dev environment (vs 2005). When i publish the site to a windows 2000 sp4 box running IIS, the global does not seem to fire. Since it's a test server,...
1
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
I have a web app that handles errors in the Gloabal.ascx's Application_Error(). It does some logging etc in there and if it throws an error, I want the app to display a static html splash page...
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
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,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.