Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I let Visual Studio 2012 detect if virtual directories need to be remapped?

My situation:
I am working on an ASP.NET MVC project and debug in IIS-Express. Sometimes when we create a temporary branch, this branch will use the same port for debugging. This means the virtual directory in IIS is the same and I can't run them both at the same time.

How it used to work in vs2010:
This is not really a problem because I don't want to run them at the same time. However, in VS2010, I would get a warning when opening the branch for the first time. It asked me if I wanted to remap the URL. When I later returned to open the trunk, I would get the same warning (See https://stackoverflow.com/a/3093534/210336). The message in vs2010

How it doesn't work in vs2012:
Now in VS2012, I don't get the warning anymore. If I forget to manually go to the settings and press "Create Virtual Directory" (This has happend a few times), then when I click run in the branch, it will actually run the trunk. This can be extremely confusing. Especially if I try to debug or the system breaks on an exception. A source file from the trunk will be opened in the branch solution. I then think I'm editting the branch, but I am in fact editting the trunk... The button in VS2012 that I need to press

Is there anyway to let VS2012 perform the same check as VS2010?

Or am I doing/understanding something else completely wrong?

like image 256
Matthijs Wessels Avatar asked Feb 05 '13 13:02

Matthijs Wessels


People also ask

How do I find virtual directory?

In the Connections pane, expand the server name, expand Sites, expand the Web site to which you want to add the virtual directory, and then click the application to which you want to add the virtual directory. In the Actions pane, click View Virtual Directories, and then click Add Virtual Directory...

Where does IIS Express create virtual directory?

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. config file.

Where are IIS virtual directories stored?

The entire IIS configuration for IIS6 is in c:\windows\system32\inetsrv\metabase.


1 Answers

VS actually edits the IIS Express configuration file found in one of these paths

%userprofile%\documents\iisexpress\config\applicationhost.config
%userprofile%\my documents\iisexpress\config\applicationhost.config

When leaving it up to VS, I tend to see duplicated and conflicting configurations.

For local development, I prefer to start IIS Express from cmd or powershell script as it does not require attaching (but can be attached) and gives me control over the configuration. I make a copy of the iis config and specify the config file in the iis express command. I have a powershell script that sets the path based on the executing directory so no matter which branch, it is always set to the one I'm working in.

Here is some information about running iis express from the command line:

http://www.iis.net/learn/extensions/using-iis-express/running-iis-express-from-the-command-line

And here is a good resource for running iis express from powershell:

https://blog.differentpla.net/post/UaYcAPDfiVJBAAAC/running-iis-express

like image 173
crad Avatar answered Nov 13 '22 08:11

crad