Debugging 2 projects locally - visual-studio

I have a Visual Studio solution that has a main web project and another secondary project that is an application under main.
The solution runs fine in production when published to IIS, but I'm having issues trying to debug locally.
Both are setup in Visual studio to run on different ports under localhost.
I can start the main web app in debug mode, but how do I start the other app so I can debug the whole solution?
Thanks!

I can start the main web app in debug mode, but how do I start the other app so I can debug the whole solution?
To achieve this, you can select Multiple startup projects on the Property Pages, please Go to Solution ->Properties -> Startup Project:
Hope this can help you.

Related

Publishing Visual studio project on localhost

I tried to search about this but doesn't answer my question. I'm currently testing my project on localhost mostly and I can't test my project if Visual studio isn't debugging so I was wondering if I have to publish my whole project to localhost or something? And if so, how do I do it and do I need something like apache or wamp for that?
The project is ASP.NET Web Forms
Just start your project without debugging (Ctrl+F5) or click on Debug -> Start without debugging.

Prevent visual studio 2010 start a local IIS

I have a solution with many types of projects, and some of them are websites. Usually, I debug a non-website projects, but everytime I start to debug any project in the solution, the local visual studio IIS starts runnning.
Is there any possible way to stop running the IIS server ???
Thanks!
Open your project and go to the projects Properties. In web apps, you should see a Web tab/choice. Click that, then you can configure which/what server you want to start. I think that the default is that VStudio likes to use it's internal IIS Express, but you can configure it to use IIS locally on the box or to use a custom server.
You can actually set the project to not start anything in the Start Action section on that 'tab' as well, and to simply wait until it registers a connection.
Note that if you are trying to debug using a non-local server, then remote debugging will have to be on on the server, which isn't a great idea in production environments.

Test Project in Visual Studio 2010 for a Windows Service Project

I am working now in a Windows Service Project and I am having a lot of headaches trying to debug the service, I found a lot of article on how to debug a service but none of them worked for me :(
How to: Debug Windows Service Applications
There is no way after attach the process to enter in my breakpoints (set breakpoints everywhere)
Then I found another creating a windows form inside the project but that Solution is kind of dirty (but a solution).Testing a Windows Service From Within Visual Studio
So the real question is, is there any possible way to create a test project to test the service? (I don't have experience with testing, but I know is a good practice)
Do you want to debug the service or code that service runs?
In the past I would create one project for a service, one project for a library that contains the logic, and one project for a console app that would be used to test and debug the logic locally. That setup covered most of the debugging needs.
Hope this helps!

Visual Studio: Unit Testing a web project in the same solution

I have a solution with a WebAPI project and a VS Test project.
My tests make calls to the API using RestSharp via a Url rather than instantiating the controller itself and injecting things (context etc).
My question, is there a way to tell the test project to launch the web project via IIS Express when a test run begins? Currently I just run two instances of VS, one with the web projected with debugging started and the other running the test package
If you are trying to debug both the test and the service, consider doing this
Launch to debug your Web service in Visual Studio.
Click Debug -> Detach All. IIS Express will keep running.
Set a break point and start Debuging your Unit Test.
(Skip this if you don't need to debug the web service) Click Debug -> Attach to Process. Find iisexpress.exe and attach.
However, you lose Edit and Continue on your web service which was detached.
I wouldn't recommend using the network to unit test Web API. You open yourself up to potential flakiness in the test and you end up testing a whole lot more than the service itself.
But if you really must do so, maybe to test that your client can exchange information with the API, then I'd suggest you look into self-hosting the service:
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/self-host-a-web-api
Self-hosting lets you start up a server for Web API with just a few lines of code and you could have your tests start up this server in the right places. In most cases, this should behave the same as having your service hosted in IIS Express. But there are some important distinctions. For example, you won't be able to use some System.Web concepts you may be used to (like HttpContext.Current).
Update:
I've written a blog post about testing Web API services that might help -
https://learn.microsoft.com/en-us/archive/blogs/youssefm/writing-tests-for-an-asp-net-web-api-service
Hope that helps.
I know this is an old post but I was just faced with this issue. I can provide a more detailed response if / when anyone reads this.
In short.. I created a console app referencing the unit test assembly and via reflection and a simple menu system you can run any one of your tests.
I then set multiple startup projects to be the Web project and the console project.
I can then F5 and debug both the unit test and the Web project from within the same session. No attaching to a process of multiple solutions needed.
Running your web service or site in release non-debug by CTRL-F5 makes it run independent from Visual Studio and you are free to run your Tests from inside VS
I know that this is late but I use this solution:
Start two instances of Visual Studios. Start debugging the API in one VS and then debug the test in another.

VS 2005 Multiple Startup Project

I've have a project which has 11 mini-project...
I choose 2 of my project to start when project is browsing...
My first project is web other one is desttop project...
While i choose start without debugging is work fine: 2 of my projects start well...
But when i choose to debug mode my desktop project is not starting, thus i can't debug my project...Just my web project is starting and thats's all, it is not working as same as in the without debuging mode...
Summary: 2 project is not working properly as same as in the debug mode and in the without debug mode...
Anytime during debugging your can right click a project in the solution explorer and start it for debugging. That way you can start as many projects as you wish.

Resources