1

I have an web application in asp.net and in web.config its written

<customErrors mode="On" defaultRedirect="error.aspx" />

Suppose i have a page abcd.aspx. And I have send a request in browser as abcd.aspx?p1=cvb&p2=dfg

Now if any error occurs its redirecting to error.aspx?aspxerrorpath=abcd.aspx. But i want to pass p1 and p2 as well as. i.e error.aspx?aspxerrorpath=abcd.aspx&p1=cvb&p2=dfg

How can i do that?

2 Answers 2

0

You can not, this is a part of the inside function call and you can not change it. Here is the function that make the redirect and its have the this.Request.Path not the full url with the parameters.

internal bool RedirectToErrorPage(string url, CustomErrorsRedirectMode redirectMode)
{
    try
    {
        if (string.IsNullOrEmpty(url))
        {
            return false;
        }
        if (this._headersWritten)
        {
            return false;
        }
        if (this.Request.QueryString["aspxerrorpath"] != null)
        {
            return false;
        }
        if (redirectMode == CustomErrorsRedirectMode.ResponseRewrite)
        {
            this.Context.Server.Execute(url);
        }
        else
        {
            if (url.IndexOf('?') < 0)
            {
                url = url + "?aspxerrorpath=" + HttpEncoderUtility.UrlEncodeSpaces(this.Request.Path);
            }
            this.Redirect(url, false);
        }
    }
    catch
    {
        return false;
    }
    return true;
}

To say few more.
When you have reach at that error page you have lost control, meaning that you ether have a programming error, or some unhanding exception. That error is logged on your EventViewer, but you can also use the Application_Error on the global.asax to personal log it and write it to your log file.

relative:
How to catch unhandled exceptions in an asp.net application?
How do I make a "generic error" page in my ASP.NET application so that it handles errors triggered when serving that page itself?

0

I would recommend looking into ELMAH for asp.net error logging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.