I can not show my error page when in url
I have a subdomain and this page does not exist.
In the configuration of my web.config
I have the following:
<system.web>
<customErrors defaultRedirect="~/ErrorPag/Error500" mode="On">
<error statusCode="403" redirect="~/ErrorPag/Error403" />
<error statusCode="404" redirect="~/ErrorPag/Error404" />
<error statusCode="500" redirect="~/ErrorPag/Error500" />
<error statusCode="503" redirect="~/ErrorPag/Error503" />
</customErrors>
</system.web>
works correctly when I access my domain in this way: localhost/ErrorPag/Error
(this page does not exist) , but if I enter this other way that is with subdomain it does not work for me: subdom.localhost/ErrorPag/Error
it shows me the following error (the typical yellow page of IIS
) :
Server error in the application '/'.
Error in runtime
Description: An exception occurred while processing the request. Also, another exception occurred when running the error page customized for the first exception. The request has been terminated.
On the other hand, if I access the error page with subdomain correctly, it shows it to me, that is, the url that I entered in the browser in this way: subdom.localhost/ErrorPag/Error404
is displayed correctly
What configuration should I have in web.config
or IIS
to work correctly?
For now I use this configuration in the web.config
, but I need to keep the subdomain, because through the subdomain I get information about the user who started the session.
<system.web>
<customErrors defaultRedirect="http://localhost/ErrorPag/Error500" mode="On">
<error statusCode="403" redirect="http://localhost/ErrorPag/Error403" />
<error statusCode="404" redirect="http://localhost/ErrorPag/Error404" />
<error statusCode="500" redirect="http://localhost/ErrorPag/Error500" />
<error statusCode="503" redirect="http://localhost/ErrorPag/Error503" />
</customErrors>
</system.web>
Note 1: Considering that it is not just a subdomain, to be more specific it is a wildcard domain (*. myDomain.com) em>
Note2: The configuration I use to capture the subdomain is in this question in
SubdomainRoute
.