Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure IIS Express to debug an application in a subdirectory?

Tags:

My web application is typically located in a subdirectory of the root in IIS. Suppose the subdirectory is "app"

When I try to debug it in Visual Studio, the path is always rooted at localhost, with no subdirectory. This messes up my paths in the application.

When I try to change the project URL's form from http://localhost:port/ to http://localhost:port/app it just says "Cannot create virtual directory." Well, that's what it said the first time, until I removed the application entry from the application.config file, then it succeeded.

When I try the "override application root URL" to the same thing, it just doesn't work. It either gets an Error 500.0 Internal Server error, or in some cases it acts like it's applying the application's web.config file to both the root and the virtual subdirectory, because it gives an error that I'm trying to add a module that has already been added (presumably in the root).

I've tried editing the project's settings in application.config for IIS Express, but no combination of settings seems to work.

I don't understand why visual studio is situating the project at an IIS Express root directory, when it knows this project is deployed to IIS in a subdirectory. I think it should match the directory structure by default.

This is what it looks like now:

<site name="app" id="5">    <application path="/" applicationPool="Clr4IntegratedAppPool">      <virtualDirectory path="/app" physicalPath="C:\Users\username\Desktop\wwwroot\app" />    </application>    <bindings>      <binding protocol="http" bindingInformation="*:3056:localhost" />    </bindings> </site> 

If I change the application path to "/app", then it gives error 500.19, saying the configuration is invalid. If I do the same thing and remove the virtual directory tag, then it fails to launch IIS Express altogether.

like image 490
Triynko Avatar asked Nov 06 '13 17:11

Triynko


People also ask

How do I debug an application deployed in IIS?

To start debugging, select IIS Express (<Browser name>) or Local IIS (<Browser name>) in the toolbar, select Start Debugging from the Debug menu, or press F5. The debugger pauses at the breakpoints. If the debugger can't hit the breakpoints, see Troubleshoot debugging.

Where are IIS Express virtual directories?

Creating a virtual directory in IIS Express To create a Virtual Directory in IIS Express simple navigate to the IIS Express' config directory located in _C:\Users<User>\Documents\IISExpress\config_ and open the applicationhost.


1 Answers

I found the answer here: https://stackoverflow.com/a/4733387/88409 Different question, but same answer.

Basically, one must create a child application, not just a child virtual directory.

<site name="app" id="5">     <application path="/" applicationPool="Clr4IntegratedAppPool">         <virtualDirectory path="/" physicalPath="C:\Users\username\Desktop\wwwroot" />     </application>     <application path="/app" applicationPool="Clr4IntegratedAppPool">       <virtualDirectory path="/" physicalPath="C:\Users\username\Desktop\wwwroot\app" />     </application>     <bindings>         <binding protocol="http" bindingInformation="*:3056:localhost" />     </bindings> </site> 

It seems to require both application entries (i.e. it requires a root application (even if it's physically an empty dummy directory) as well as the child application). If I omit the first application entry at the root, then it gets error 500.19 "The requested page cannot be accessed because the related configuration data for the page is invalid." With both application entries, however, it works without any issues.

As far as I can tell, there is no way to produce the above settings in Visual Studio, so it must be edited manually in application.config. These settings are therefore completely disassociated with the web application project files themselves, which isn't good, IMO.

like image 92
Triynko Avatar answered Oct 29 '22 13:10

Triynko