I have a .net mvc application(standard) and trying to implement custom errorhandling using httpErrors
in web config.
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="Redirect">
<clear />
<error statusCode="404" path="http://localhost/E_HealthCare_Web/Views/Error/NotFound404" responseMode="Redirect" />
</httpErrors>
</system.webServer>
although it redirect to specified path but I get a http 403 error stating You do not have permission to view this directory or page. I think its an iis error but don't know how to solve it. if it needs a permission then where should I go to get the permission or should I set it up.
EDIT as mentioned in the comment i tried using absolute Url and i got localhost redirected you too many times error and i tried clearing cookies as i tried clearing cookies but its not working and it is redirecting to the same page infinitely as you can see below.
Another Edit
Thanks to @LexLi and @JennyDai i finally solved this by changing my path in web.config to to path="http://localhost/E_HealthCare_Web/Error/NotFound404"
by using mvc's proper route URL pattern.
CodePudding user response:
As Lex says, redirects client browsers to a different URL that contains the custom error file, the path value has to be an absolute URL instead of a relative path. After trying to change the path, see if there is still an error.
CodePudding user response:
Thanks to @LexLi and @JennyDai i finally solved this by changing my path in web.config to to path="http://localhost/E_HealthCare_Web/Error/NotFound404" by using mvc's proper route URL pattern.