How to pass additional parameter to error page

P

pawel.pabich

Hajo,

I use <customeErrors> and I set the defaultRedirect attribute to my
error page.
Now I want to pass to this page additional number and I want to do this
using query string but I do not know how to add additional paramter to
automatically generated by asp.net url.

error.aspx?aspxerrorpath=/OnlineForms/Sandbox/Pawel/RaiseException.aspx

In short, how to change it into this:

error.aspx?aspxerrorpath=/OnlineForms/Sandbox/Pawel/RaiseException.aspx&parm1=as

thanks in advance for any info

Pawel Pabich
 
T

Tim_Mac

hi Pawel,
i don't think you can fiddle with the defaultRedirect querystring. however,
if you intercept the Application_Error event in global.asax (which happens
regardless of custom errors setting), this allows you to act before the user
gets redirected to the error page. you could put code in this event to
Redirect the user to /error.aspx?blahblah&NewParam=blah, and end the
response there. this is basically not using customErrors, so you might as
well turn it off. but since you want to override the default behaviour, it
is probably the best thing to do in your situation.

where does the extra parameter value come from? what is it used for?

hth
tim
 
P

pawel.pabich

Thanks for answer. Yes I can completly fresign from customerrors but I
thought that
I can use it and customise. The extra parameter is code of error. I can
not use session because I clear everything in Application_Error. For
now I use cookie and it works.

Pawel Pabich
 
T

Tim_Mac

hi pawel,
you can use Server.GetLastError() to get the last exception in your
application.
this is the code i use in my Application_Error event in global.asax:

Exception ex = Server.GetLastError();
if(ex != null)
{
if(ex.GetBaseException() != null)
ex = ex.GetBaseException();
// ... log it

hopefully with this you won't have to pass the error around, and you can go
back to using custom errors :)
tim
 
P

pawel.pabich

Hi Tim,

the problem is that HttpApplication objects are pooled and two
subsequent request can be handled by different objects.

Pawel
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top