Custo404Redirect Error iis8
Hi,
Custom404 Redirecting is Successfully Redirecting in local system, But its not Working in Server(windows server 2012, IIS8),
Here is my code:
<customErrors mode="On" defaultRedirect="~/not-found">
<error statusCode="404" redirect="~/custom404" />
<error redirect="~/not-found" statusCode="403"/>
</customErrors>
Please help me how to Solve this,Here I'm Attaching Error Screen Shot,
Thanks & Advance
Ajay
Hello Ajay,
The <customErrors> section handles only the ASP.NET errors. When you host your site on IIS you also need to configure the IIS to return your custom error pages whenever it encounters an http error on your site.
In order to configure the IIS error handling you need to add the following code under the <system.webServer> section in the web.config file:
<
system.webServer
>
...
<
urlCompression
doDynamicCompression
=
"true"
doStaticCompression
=
"true"
dynamicCompressionBeforeCache
=
"false"
/>
<
httpErrors
errorMode
=
"Custom"
defaultResponseMode
=
"ExecuteURL"
>
<
remove
statusCode
=
"404"
/>
<
error
statusCode
=
"404"
path
=
"/custom404"
responseMode
=
"Redirect"
/>
</
httpErrors
>
...
</
system.webServer
>
I am having a similar issue with the custom error pages. I can get them to redirect, but how do I get them to return a 404 status code? Right now the page is returning a 200 status code with the bad urls.
<
customErrors
mode
=
"RemoteOnly"
defaultRedirect
=
"~/error/generic.aspx"
>
<
error
statusCode
=
"403"
redirect
=
"~/error/403.aspx"
/>
<
error
statusCode
=
"404"
redirect
=
"~/error/404.aspx"
/>
<
error
statusCode
=
"500"
redirect
=
"~/error/500.aspx"
/>
</
customErrors
>
<
httpErrors
errorMode
=
"Custom"
defaultResponseMode
=
"ExecuteURL"
>
<
remove
statusCode
=
"404"
/>
<
error
statusCode
=
"404"
path
=
"/error/404.aspx"
responseMode
=
"ExecuteURL"
/>
</
httpErrors
>