• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1102
  • 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
 
pippenAuthor 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
pippenAuthor 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
 
pippenAuthor 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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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