Last post Sep 26, 2014 01:54 PM by colelaus
Sep 24, 2014 06:36 PM|colelaus|LINK
I'm trying to locate the page that caused a defaultRedirection.
In my web.config file I have:
<customErrors mode="On" defaultRedirect="~/DefaultError.aspx">
when I attempt to access a page that does not exist on my development system, it properly redirects to the DefaultError page with the following in the address bar:
/BadDisplayPath/BadDisplayName.aspx is the name of the page that caused the redirection and is the information I need access to in my code.
If I use the following or any of its variants
I get something back similar to
http://localhost:52247/DefaultError.aspx?aspxerrorpath=/favicon.ico but not anything that contains the name of the page that caused the redirection.
How can I get the actual URL and Query String that are displayed in the address bar?
Thanks for your help
Sep 24, 2014 09:38 PM|oned_gk|LINK
string aspxerrorpath = Request.QueryString["aspxerrorpath"];
Sep 24, 2014 10:04 PM|colelaus|LINK
I tried your suggestion
but with no success. I received
/favicon.ico back. I guess I would expect that given that it was also returned in my url request. I'm staring right now at the bad .aspx name in my address bar but I can't seem to access it! I really don't have a clue why /favicon.ico is returned.
Sep 26, 2014 01:54 PM|colelaus|LINK
After looking into this a little more, it appears I only have this problem for the page specified in the defaultRedirect specification while those listed for specific status codes appear to work fine. My customErrors specification looks like the following
in the web.config file:
<customErrors mode="On" defaultRedirect="~/ErrorPages/ErrorDefault.aspx">
<error statusCode="404" redirect="~/ErrorPages/Error404.aspx" />
In the above code, ErrorDefault.aspx and Error404.aspx are the exact same html/code with different names. The correct query string is returned to the Error404.aspx page, but the wrong query string is returned by ErrorDefault.aspx. I have to believe it
has something to do with being the default page at this point.
Any help would be appreciated!