Andy Johnson
Andy Johnson

Reputation: 8149

ASP.NET Development Server

I have a solution that contains a number of projects. One is an asp.net project, and is set-up to use the asp.net development server. The other projects have nothing to do with asp.net: for example, some are windows services written in unmanaged c++, others are c# console applications.

My problem is that if I start any of the non-asp.net projects in the debugger, Visual Studio still starts the asp.net development server. This causes problems when I am debugging program interactions using multiple instances of visual studio. When I debug the web application I do want the web server to start.

I have noticed that when I debug a non-asp.net project, the asp.net development server is started using the port number and virtual directory specified in the asp.net projects properties. There are no project dependencies between these projects.

Is there a way to tell visual studio to start the development server only for projects that actually specify that it should be used?

Edit 1: To reproduce this behaviour:

  1. Using vs2010, create an empty solution.
  2. Add a c++ console application accepting all the defaults. Add a call to fgetchar() to the generated main() so that it doesn't immediately exit when it is run.
  3. Run the project in the debugger and notice that the asp.net development server does not start.
  4. Add an asp.net web application project to the solution, accepting all the defaults. Go to the project properties web tab and verify that it is configured to use the asp.net development server.
  5. Set the c++ console application to be the startup project, and then start the c++ project in the debugger. Notice that the asp.net development server now starts, even though the web application project is not running.

Edit 2: Clarified that I want the server to start when I debug the web project, but not when I debug the other non-web projects.

Upvotes: 1

Views: 1159

Answers (2)

Andy Johnson
Andy Johnson

Reputation: 8149

I have a solution that works for me.

It appears that web projects have a property that controls whether the asp.net development server is started when the debugger starts, even if the web project is not itself being debugged.

To change this property, select the web project in the solution explorer and press F4 to access a property grid. In the grid, under the heading Development Server, is a boolean property named Always Start When Debugging. The default value is true.

When I set this property to false the asp.net development server no longer started when I debugged a non-web application project.

The property is persisted in <ProjName>.csproj.user, not <ProjName>.csproj.

Upvotes: 2

Matt
Matt

Reputation: 1678

In the properties of the web project, under the tab "Web" you can change the startup behaviour to "Use Custom Web server". This will stop VS invoking IIS or the ASP.NET Dev server instance.

Upvotes: 0

Related Questions