0

My URL is like http://app.test.com/asp/default.aspx

When user mis types URL like http://app.test.com/asp/defaul123t.aspx and hits i am redirecting to custom error page pagenotfound.html. For this i made changes in

INETMGR-->Websites-->Defaultwebsite-->Mywebsite-->Properties-->CustomErrors--> For HTTP Error 400

I set the file path for pagenotfound.html

But my problem is when user mistypes URL like http://app.test.com/asp/www.google.com I am not getting redirected to custom page not found page pagenotfound.html

instead it is showing internet explorer http404 page

The page cannot be found The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Please help me in resolving the same.

Luthando Ntsekwa
  • 4,192
  • 6
  • 23
  • 52
user1463065
  • 563
  • 2
  • 11
  • 30
  • 1
    Actually 400 and 404 are different HTTP status codes, if you want to redirect to pagenotfound.html you should set custom error for both. Difference is _who_ (IIS/ASP.NET) returns 404 error. Check also [this post](http://stackoverflow.com/q/667053/1207195). – Adriano Repetti Apr 22 '15 at 12:01
  • possible duplicate of [IIS7 custom 404 not showing](http://stackoverflow.com/questions/6648007/iis7-custom-404-not-showing) – xDaevax Apr 22 '15 at 12:05

1 Answers1

1

You need to try like this:

<customErrors mode="On" defaultRedirect="~/Error/YourErrorPage.aspx">
     <error statusCode="404" redirect="~/Error/404.aspx" />
</customErrors>

Also check <customErrors> Element and Displaying a Custom Error Page

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331