Configure error pages from web.config or IIS with a subdomain

3

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 .

    
asked by JuankGlezz 15.05.2017 в 22:39
source

1 answer

1

You could try adding an error page to your site from the IIS in the IIS configuration.

To do this you would have to Abrir IIS->Selecciona el sitio-->Haz doble clic en Páginas de errores de .Net-->click derecho y agregar.

In the window that opens you will have to add an error code, in your case 404 and the Absolute URL of your error page.

If this does not work for you, you could try adding the custom error page for the IIS domain itself () the container of your sites.

Or as another option, you could do it from the DNS configuration itself, adding a record to redirect all subdomains (*) to the entire domain

    
answered by 22.08.2017 в 16:42