Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable aspxerrorpath parameter in ASP.Net URL

I've added the following to my web.config to redirect a user to a custom error page instead of the default

Server Error in '/' Application.

error message.

The user get's redirected to error.html?aspxerrorpath=/paymentservices.svc

Is there a way to remove the ?aspxerrorpath=/paymentservices.svc part?

web.config:

<system.web>
    <customErrors defaultRedirect="~/ErrorPages/error.html"
  mode="On" xdt:Transform="Replace">
    <error statusCode="500" redirect="~/ErrorPages/error.html"/>
    <error statusCode="404" redirect="~/ErrorPages/error.html"/>
    </customErrors>
</system.web>
like image 887
Bhav Avatar asked Aug 10 '26 11:08

Bhav


2 Answers

A cheap way is to just add your own query string to end of the error - it should overwrite the "default" one. Even an empty string should work.

<error statusCode="500" redirect="~/ErrorPages/error.html?"/>

Or you could add your own error handling to Application_Error in Global.ascx

like image 157
danielmcn Avatar answered Aug 13 '26 02:08

danielmcn


You could try rewriting the response

<customErrors mode="On" redirectMode="ResponseRewrite" >
    ....
</customErrors>
like image 20
Reuel Ribeiro Avatar answered Aug 13 '26 03:08

Reuel Ribeiro