Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying relative path in web.config

We encountered a problem after deploying our MVC3 Asp.net application to a client's site.
In the client site, a virtual directory has been created in IIS7 to which we need to deploy.

The problem is in web.config where we have specified a custom error page as

<!-- Custom Error Pages -->
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="-1" />
      <remove statusCode="500" subStatusCode="-1" />
      <remove statusCode="403" subStatusCode="-1" />
      <error statusCode="404" path="/Error/Http404" responseMode="ExecuteURL" />
      <error statusCode="403" path="/Error/Http403" responseMode="ExecuteURL" />
      <error statusCode="500" path="/Error/ServerError" responseMode="ExecuteURL" />
    </httpErrors>

The error page paths are not working properly. After an investigation, we found that I have to specify the virtual directory and set the path to /virtual_directory/Error/Http404

Is there a way I can specify the path relative to the virtual directory?

like image 218
Robert_Junior Avatar asked Nov 12 '22 17:11

Robert_Junior


1 Answers

If the virtual directory path is constant in your deployment environments, this answer might serve your purposes, with different web.config and web.release.config files.

If the virtual directory path can vary, the original questioner says it's not possible.

like image 169
Michael Avatar answered Nov 14 '22 23:11

Michael