locked
custom error paths in web.config when application is run as a subfolder. RRS feed

  • Question

  • User1773436720 posted

    Hi, quick question.

    I'm playing around with custom errors. I have a path issue. The app is running as a sub-folder in IIS. My error handling is as follows:

    <error statusCode="404" subStatusCode="13" prefixLanguageFilePath="" path="~/AppErrors/30000.aspx" responseMode="Redirect"/>

    This yields a URL of "http://myapp.com/aspnetappSubfolder/folder that App was in when 404 happened/~/AppErrors/30000.aspx".

    This is obviously not right as the AppErrors folder is off the root of the application. How do I handle this path issue?

    Thanks

    Friday, June 17, 2016 6:45 PM

Answers

All replies

  • User-782232518 posted

    IIS configuration elements under <system.webServer> do not honor ASP.NET syntax, so that you cannot use "~" like you used to in ASP.NET. 

    https://www.iis.net/configreference/system.webserver/httperrors/error

    You must use an absolute path as described in this page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 18, 2016 2:21 AM
  • User1773436720 posted

    Thank you! Yes after reviewing the article it seems that responsemode dictates path requirements and that the only 'relative' option is relative to the web server not the application.

    Monday, June 20, 2016 4:37 PM