Aspxerrorpath Querystring

J

Jelle Huygen

Hello,

I have a problem with the aspxerrorpath.

When I have a page that doesn't exists the 404Error.aspx page is
called. There I can get the page that didn't existed with the
aspxerrorpath variable.

The problem is that when I have a page for example with
Detail.aspx?id=xxx. And this results in a 404-error, I can't retrieve
the 'id=xxx'-parameter. The aspxerrorpath-parameter contains only
'Detail.aspx'. Does anyone know a solution for this?

The problem is the same when other error occur (for example a
500-error is redirected to 500Error.aspx).

Kind regards

Jelle
 
Joined
Nov 16, 2009
Messages
1
Reaction score
0
That should be easy...

Try adding this to the Global.asax in your project

Code:
        protected void Application_Error(object sender, EventArgs e)
        {
            HttpApplication ha = (HttpApplication)sender;
            CustomErrorsSection customErrors = (CustomErrorsSection)ha.Context.GetSection("system.web/customErrors");
            if (customErrors != null && customErrors.DefaultRedirect != null && customErrors.DefaultRedirect.Length > 0 && customErrors.Mode == CustomErrorsMode.On)
            {
                if (!ha.Request.RawUrl.ToLower().Contains(customErrors.DefaultRedirect.ToLower()))
                {
                    Response.Redirect(String.Concat(customErrors.DefaultRedirect, "?aspxerrorpath=", ha.Request.Url.LocalPath, ha.Request.Url.Query.Length > 0 ? Server.UrlEncode(ha.Request.Url.Query) : String.Empty));
                }
            }
        }
 

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,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top