Debugging a solution with multiple projects - asp.net

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 .

Related

How do I publish a Web Forms Application from VS2017 to IIS from Intranet?

I have developed an ASP.NET Web Forms Application in Visual Studio 2017(CE). It's the project that I've developed for my college, as an objective to run it as an Intranet Application so that it could run on a IIS on a PC and people can access it over the Intranet. I've tried using the Web Deploy method, generated a Folder and addressed the IIS to the Published files of Visual Studio. But I don't get it to work, and I feel it's not the right way.
I've tried some research but haven't been able to figure out the right context. Can anyone please recommend me the right place of instructions? Or instruct here itself?
Go to Solution Explorer and select the project then right-click the project
Click the Publish menu item then left panel to publish screen will be open like below screen
Select the publish option as IIS, FTP, etc then click to publish button
The publish window will be open then select publish method as File System and type the Target location as http://localhost/Appname and click Next button.
Now, you can see the setting and file publishing options whatever you want to configure the options and click the Save button
Now you can find the application was published URL http://localhost/App in the output window

Deployment of web application in VS 2012 to my server

I have Web Application which I would like to deploy to my web server. I do not want to use Windows Azure, I have my own server. I even do not have my profile to publish to Azure. I believe it is OK to not have the profile and continue using VS2012. I would like have complied binary files and all my pages (master, aspx) together with my controls (ascx), js, css files and without code-behind files placed in my local folder. Then I plan to pack them and copy to my server through FTP. Sounds trivial. But...
When I hit right click over my Web Application project and then "Publish...", I have Publish Web window. The first step asks me if I want to publish to Windows Azure. In this case I have to provide my profile which I do not have. I do not need it. I just want to deploy to my local folder all except code-behind files. I cannot choose the next step which is "Connection". So I hit "Publish" button. And now, now I am stuck, because I have to provide my profile (see attached screenshot). Could you tell me how I can prepare my web application for deployment to my web server? Thank you.
If you are not planning on using Azure, simply ignore the statement at the top of that screen, it is only helpful if you are publishing to Azure.
To get past this step, click on the drop down and then click "New profile".
After that you will be taken through the rest of the wizard were you can setup your connection details etc.

Visual studio 2010 creates new project every time I open a web site

I am working for a client who has a number of ASP.NET web sites (as opposed to ASP.NET web applications). Each time I open up one of these websites in VS2010 I have to tell Visual Studio to use IIS Express, and for older websites I have to tell VS2010 that I do not want to convert it to .NET 4.
I can see in the title bar, once the website has been loaded, that a new solution file is created each time, because it displays "[websitename] (NN)", and each time I load the web site NN increases by 1.
It would be handy if I could simply open up the solution file directly, or alternatively change a setting somewhere that tells VS2010 to use the existing solution file for this site.
Does anyone know if this is possible?
Here are the steps required to achieve that:
Add an empty solution by clicking File -> New -> Project -> Other project types -> Visual Studio Solutions
In your solution explorer which should show nothing except the one entry for your empty solution, right click on that solution entry, click Add -> Existing website, then find the existing website in your file system and confirm.
Done.

Why so many instances of ASP.NET Development Server?

I am debugging a large web application solution, with the main web application project as a single startup project, configured to use IIS for debugging. Whenever I run this application inside Visual Studio 2010, I still get multiple instances (sometimes over 15) of the ASP.NET Development Server starting up as well. Why does this occur?
Visual Studio has a setting in every Web Project's properties by default to start the development server when you are debugging. This enables, for example, a web project which contains Web Services to be available when you've selected a client web site or application to start.
If you do not want this behaviour follow these steps:
Select the web project
Open the "Properties" window by pressing F4
Change the Always Start When Debugging value to False
Repeat steps 1-3 for any other web projects in your solution
Source: '"Always Start When Debugging" – Preventing multiple Visual Studio Development Servers from starting' by by Kevin Rintoul
A simple solution if you have many web projects in the same solution: from the Package Manager console:
get-project -all | %{ $_.Properties | ?{ $_.Name -eq "WebApplication.StartWebServerOnDebug" } | %{ $_.Value = $False} }
This will change all web projects Always Start When Debugging setting to false with a single command.
My setup is similar to yours (except I use CassiniDev ( http://cassinidev.codeplex.com/ ))
Go to all your secondary sites project properties : click "use Custom Web Server", set something in "Server Url" (for exemple http://your-iis-server:your_port/your_project, but it may be even invalid)..
This will prevent the automatic startup of Cassini for the secondary web sites.
Leave your main site in the original configuration.

How can I use the "Publish" function in Visual Studio 2008 without erasing the contents of the target folder?

When I use Build->Publish Web Site in Visual Studio 2008, most of the time it compiles the site, and then simply asks me "All files in the target folder will be deleted. Continue?" (or something to that effect). On occasion, however, when publishing a project in Visual Studio, I would get a dialog box that would give me the choice of replacing the folder's contents completely, or simply replacing changed files with newer version.
I much prefer to publish without completely obliterating the folder, because the deployed application creates user files and cache files as it's been used that I don't want to take extra steps to preserve. However, I'm not sure why Visual Studio doesn't always give me this option. Is this a setting somewhere I can change? Is it tied to the version of .NET I'm using?
Any insight is appreciated!
Edit - Followup on 2009-01-20
I still haven't figured this out, but here's some more information.
Here's what the publish function looks like for one ASP.NET project on my Win XP desktop:
And here's what it looks like for a different project on my Vista laptop:
Notice the radio buttons in the second screenshot that allow me to choose to either delete the contents of the folder prior to publishing, or merely to overwrite matching files. I'd like to have these options for every project.
Both computers are running Visual Studio 2008 Professional (version 9.0.30729.1 SP, according to Help->About). The exact same version. And I doubt the OS difference is causing this functionality change. It's got to be a setting somewhere, right? Does anyone know?
John is right, the only difference is one of your projects is a Web Site Project and the other is a Web Application project. You will not see the "convert to web application" option unless you are in a Web Application project. I know... it is very misleading. The reason behind this stems from the the way you convert to a web application project. If you plan on converting it(which can be a real pain in arse, depending on how it is set up) then you need to be aware of a few differences:
In a Web Application project everything is pre-compiled all the codebehind pages will be compiled into a .dll ---- In a Web Site Project nothing in the project is pre-compiled, the compiler will compile everything to ensure it is valid but none of the compiled pages are uploaded. When a user first attempts to access the site each page is compiled into its own dll. This means in a Web Site Project you are able to upload a single codebehind file.
Namespaces - In a Web Application project namespaces are created by default in a Web Site Project they are not. So you may have to spend some time adding them if you plan on converting them.
Project files - you will notice that A Website Project does not have a "cproj" file a Web Application project does.
I have converted a few of these project I find they go fairly smooth as long as there is not a lot of code in the "app_code" folder. You can give it a try and see how easy it is, if it looks like it is going to be a pain, I would suggest FileZilla just FTP it and save yourself some headache.
Good Luck
That dialog is different for Web site projects and Web application projects. In my MVC projects (Web application projects), I see the additional options. In my regular ol' web site projects, I see the first dialog posted.
Not sure if this option will be suitable for you but you could use the copy website function from the solution explorer. Click on the "Copy Website" icon at the top of the solution explorer.
I think the real answer to your question is that you should put your user files and cache files somewhere else.
When publishing a web site Visual Studio is designed to make sure that the target folder contains your web site files, and absolutely nothing else.
Apparently this feature is coming in VS2010 - that's what Vishal Joshi announced at TechEd EMEA in session "PDC307: Microsoft Visual Studio 10: Web Development Futures"
The site has been updated from the site in the updated layer.

Resources