I'm developing a stateless Asp.Net app that runs in Kubernetes, so there's many instances of it running at once.
I want to debug it this way as well, so that I can spot bugs that might not happen if you debug on just a single instance. Think of authentication cookies not working correctly for example: works great on one instance, not at all if you don't set up data protection correctly.
Is there a way to run and debug multiple instances of the same Asp.Net project in Visual Studio 2019?
I am trying to debug a project I inherited. This basically consists of an ASP.NET website hosted in IIS (local IIS not express though), and a number of other projects for example a project containing the model, another project containing the Data Access, another project containing control classes etc.
I have added the ASP.NET IIS hosted website to my Visual Studio solution by Right Clicking Solution > Add > Add Existing Website ...
When I debug the website (by setting it as the startup project) from Visual Studio, it launches and works OK so for example I manage to connect to the Web Services hosted on another server, login etc etc.
However I am finding problems to hit the breakpoints on the other projects, such as XXX.Web.Model, which contains source code I need to debug.
What settings can I modify to hit the breakpoints? I tried attaching w3wp.exe but to no avail.
You might need to set multiple startup projects, and for each of the projects you want to debug set it to 'Start with debugging'. To do that on the solution node in Solution Explorer right click and choose Properties then in the dialog go to the Startup Project tab. As shown in the image below.
Docs are over at https://learn.microsoft.com/en-us/visualstudio/ide/how-to-set-multiple-startup-projects?view=vs-2017 .
In some of the solutions we have ASP.NET/WCF web project and a test project. Some of the tests run against ASP.NET development web server using http://localhost:port/.... In VS2010 while the ASP.NET/WCF web project was being debugged, the test runner could run the tests and if there were any breakpoints in web project, the debugger would break the execution. This seems to have been disabled/removed in VS2012.
When the ASP.NET/WCF web project is debugged (launched by pressing F5 or via attach process), both the TEST->Run and TEST->Debug sub-menus are disabled. In VS2010 only Test->Debug sub-menus were disabled while Test->Run sub-menus were still enabled. We use this way to easily debug the services within the web project. Any way to get that behavior back or workaround?
Debugging While Running on ASP.NET Development Server doesn't seem to be applicable to VS2012 or at least I can't get it to work.
In VS2013 the situation is the same: the options for running / debugging tests are greyed out while the project is being run/debugged. This is a shame especially for projects like web API's where tests for calling the API via HTTP (as opposed to creating an instance of the Controller class and circumventing any network traffic) are very useful as they are closer to what the end users of the API will experience.
As a workaround, you can either open the same solution in a separate instance of VS, or create a separate solution with the same projects, specifically for testing. Debug in the first VS instance, run tests in the second one.
If you have a solution with WCF applications and tests calling them, you can debug the applications using the tests by calling Debug All Tests or Debug Selected Tests without a previous Start Debugging (F5).
Configure your solution to Multiple Startup Projects with None set in all actions and configure your WCF applications to the start action Don’t open a page. Wait for request. With this configuration the development web server starts if you select Debug All Tests or Debug Selected Tests.
Here is a workaround to debug a single unit test along with a web server. It relies on Debugging Multiple Processes (excludes MSVS Express):
Start web server (non-debug), note its process id (IIsExpress icon -> Show All Applications)
Place a breakpoint at first line in test
Start Debuging the Unit Test, wait for it to stop at the breakpoint.
Debug -> Attach To Process, enter web server process id
Both the test and server are running live in the debugger.
I ended up writing a quick addon. It turns out that like VS2012, VS2012 test runner can also run the tests when the web project is being debugged. It is just that menu options are disabled.
Try this:
Place a breakpoint in the first line of your unit test method.
Start debugging your unit test.
Once it hits the first line in your unit test, start a new instance of the other projects you need running.
This is not a pretty solution, but it works. Using Azure DevOps TFS Version Control, create a branch of your current project. Open the solution for your project, in the other branch, in another instance of Visual Studio at the same time as your main project is running in the first/original instance of Visual Studio. Then, run your web project in your first/main Visual Studio instance. Now, run your unit tests from the other instance of Visual Studio. Voila.
To keep them in sync, you can do Merges from one branch to the other.
I still ran into this on VS 2022.
If you have multiple projects you can run. Try to set the startup projects and set at least two of them. (solution->right click)
If two instances are running in debug mode, VS also allows you to start unit tests.
(I just started two aspnet api-s from my project)
I have a solution with a few projects in it, one of which is a web site. When I run one of the non-web projects (e.g. a console app), the ASP.NET Development Server starts up anyway.
I'm sure there was an option for this somewhere - how do I make the ASP.NET Development Server start only if I am running the web project?
Yes, if you select the project, there is a start when debugging option (or similarly named) in the project properties window in VS; setting this to false disables this.
HTH.
I have a solution file containing multiple web applications and components. Mostly these web applications operate independently of one another, but I need to be able to response.redirect from one application to another. This works, and the new page runs, but I can't step into the code in the second web app and debug it.
I have both web applications set to "Always Start When Debugging" = True, with the first web app (the one that's redirecting) set as the startup web application. Does anyone know a trick that will let me step into the code in the second web application?
Open up a second instance of Visual Studio, then Ctrl+Alt+P (menu Tools > Attach to Process) then attach to the appropriate web server process (if you run under IIS this may be w3wp.exe or aspnet_wp IIRC, if you use the built in web server then attach to the process which lists the appropriate port for your project).
Optionally just run the second one and manually go to the first one in your browser by entering the appropriate address and trigger the redirect which you have verified is working.
Are both web applications running in the same process? What version of ASP.Net, IIS, and the .Net framework are you using? Those are my initial questions before I start giving other ideas.