Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass values into custom Error page 1

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
I am using ASP.NET 2.0
When I have an error within my webpage.
What I would like to do is read a value from the URL and pass it into the custom error page.
Can I pass values into the custom error page?

Right now I have this code in my web.config file
Code:
<customErrors mode="On" defaultRedirect="MyErrorPage.aspx">

Thanks
 
Can I pass values into the custom error page?
[/qoute]
What will you be doing with them on the page? Displaying them or just logging them?


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
instead of custom errors I use the HttpApplication.Error event catch exceptions, log and transfer to another page.

from here you can do whatever you want
Code:
public class Global : HttpApplication
{
   public Global()
   {
       Error += LogExceptionAndRedirect;
   }
   public override void Dispose()
   {
      Error -= LogExceptionAndRedirect;
   }

   private void LogExceptionAndRedirect(object sender, EventArgs e)
   {
       Logger.Log(Server.GetLastError());
       Context.ClearError();
       Server.Transfer("~/Error.htm");
   }
}
within LogExceptionAndRedirect you could do whatever you want. so you could get the current response, prase the url and pass to your error page.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Howdy Jason,

That is what I was looking for.
Thanks and star to you.

ksbigfoot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top