• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1110
  • Last Modified:

Send parameters to custom error page

I created a custom error page for an asp.net 2.0 site written in VB and I'm calling it from the web.config in <customerrors>  

We have a ticket variable that gets passed around to the various pages in the URL (HTTP, Get Variable), and I'm wondering if there is any way I can send this to the error page (without using session vars - this company doesn't want to use them). The reason is so that the user does not have to log in again after the are on the error page.

It should be in the Request.QueryString, and I tried grabbing it from that,  but I don't think it still exists by the time it gets passed over to the error page.

I know this is a weird one, but  I wanted to at least give it a try. I'm not finding anything  helpful through google search.

Also, I don't want to re-write all the try-catch phrases, because there are too many of them, but if you have ideas on that regard, I will save them for future reference when we redesign the site, and would consider giving partial points.
0
pippen
Asked:
pippen
  • 3
  • 2
  • 2
3 Solutions
 
ransommuleCommented:
I think you should handle global asax application error event and pass parameters as session variables.

    protected void Application_Error(object sender, EventArgs e) {
        Application["Exception"] = Server.GetLastError();
    }

And in the custom error page ->


            if (Application["Exception"] != null && Application["Exception"] is Exception) {
                Ex = (Application["Exception"] as Exception);

//do some stuff with the exception

                Application.Remove("Exception");
            }
0
 
CodeCruiserCommented:
>It should be in the Request.QueryString, and I tried grabbing it from that,  but I don't think it still exists by the time it gets passed over to the error page.

That I think is the only option besides session variables unless you can use files/database etc.
0
 
pippen.NET Software DeveloperAuthor Commented:
Thanks for the quick response. That might be an option when we totally redesign the site, but I'm not supposed to be using session vars for this current fix.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
pippen.NET Software DeveloperAuthor Commented:
I don't think they would want to store this particular parameter in a database or file, just because it gets generated so often, but if I did want to do it that way, would I need to use the global.asax page to pull it?
0
 
CodeCruiserCommented:
You would retrieve it wherever you need it.
0
 
ransommuleCommented:
Another option could be, (i am not sure), combining in global asax events Application Error and Authenticate Request.

In Authenticate Request it could be posible to add in query string the information you want.

   protected void Application_AuthenticateRequest(object sender, EventArgs e) {
        string strUrl = string.Empty;
       
        strUrl = ((System.Web.HttpApplication (sender)).Request.AppRelativeCurrentExecutionFilePath;

//to avoid stack overflow -> strUrl.IndexOf("?")
        if (strUrl.IndexOf("/Error/formError.aspx") >= 0 && strUrl.IndexOf("?") < 0) {
Response.Redirect("/Error/formError.asp?ErrorParameter1");
}
0
 
pippen.NET Software DeveloperAuthor Commented:
I got sidetracked from this task, and have not verified that this is the exact solution down to the nitty gritty details, but it is definitely on the right track and a great help. Once it is implemented, I will try to remember to come back and make comments. Thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now