Application_Error not Transferrig to custom page

M

MattC

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
 
M

Michael Tkachev

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

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
 
M

MattC

Yeah that is my solution if I cant resolve my current problem but shouldn't my current method work?
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

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
 
W

William F. Robertson, Jr.

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

Yeah that is my solution if I cant resolve my current problem but shouldn't
my current method work?
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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top