Cool Mike
Cool Mike

Reputation: 65

Passing querystring to Custom ErrorPage in IIS

I want to redirect all errors to one error page, so in the web.config file, i have inserted :

<httpErrors errorMode="Custom" existingResponse="Auto" defaultPath="/error.html" defaultResponseMode="Redirect">

It works fine but I want to add more option. here is how I want it to be :

Imagine the url of the website is : www.examplesite.com

I want when the viewers changed the url like this :

www.examplesite.com/aaaaaaa

it will be redirect to :

www.examplesite.com/error.html?path=aaaaaaa

I do not know how can I implement this .

thanks in advance.

Upvotes: 3

Views: 1612

Answers (1)

Izzy
Izzy

Reputation: 6866

Something like this should do

<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="404"/>
  ...
  <error statusCode="404" responseMode="ExecuteURL" path="Path to your error page"/>
 ...
</httpErrors>

Incase you want to know the differen between customErrors and httpErrors you can refer to this answer

Upvotes: 2

Related Questions