Debugging two web applications in asp.net - asp.net

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.

Related

a second ASP.NET web app hangs after deployed as IIS 'nested' Application onto primary web site

My IIS nested application hangs when I browse from IIS -- browser's busy spinner just spins forever.
I added a 2nd VS ASP.NET web app project to my primary web site, as a IIS 'nested' application.
The 2nd web app project debugs from VS OK and opens browser to it.
Is it possible to break in with debugger to see if code is in a loop or something?
BACKGROUND:
IIS 6.5 on my Windows Server 2012 R2 Azure VM
VS is 15.3.4
IIS > Sites > my primary web site > TEST (this Application added to primary) > Advanced Settings:
App Pool = DefaultAppPool
Physical Path = path to TEST's VS project
Virtual Path = /TEST
IIS 6.5...
Test Settings...
If you aren’t sure what issue is causing your website to spin forever, look at the live requests within IIS. From the IIS Management Console select Worker Processes.
Right click on your running application pool and select “View Current Requests”.
This will bring up a list of the currently running ASP.NET web requests as shown below.
I would suggest looking at the “Time Elapsed” to see if you have a lot of requests that are taking a very long time. You should also see if they are all stuck in the same module. This could be a clue that the issue is all related to ASP.NET Sessions or some other step within the ASP.NET request life cycle. You may also be able to identify a specific URL that is causing the problem.
Also in addition to that , I would highly suggest using a logging framework like NLog, log4net or Serilog. You can then send them to a log management service to make it easier to search them across multiple servers. Application logs are good way to trace your application trace across server.
If your web request is returning a 500 Internal Server Error, you need to check your server-side logs for exceptions. As mentioned above about application logs in general, it is important to have good exception handling in place and properly logging all of your errors.
Also you could use some open source diagnostic tool like Glimpse to trace. Glimpse is a thriving and growing family of open source NuGet packages that provides detailed performance, debugging and diagnostic information for ASP.NET apps. It's trivial to install, lightweight, ultra-fast, and displays key performance metrics at the bottom of every page. It allows you to drill down into your app when you need to find out what's going on at the server. Glimpse provides so much valuable information we recommend you use it throughout your development cycle, including your Azure test environment. While Fiddler and the F-12 development tools provide a client side view, Glimpse provides a detailed view from the server. You can try using that too.
Hope it helps.

Switch from consumer application to WCF (servicestack) by debugging in Visual Studio

I am developing one product and there are 4 separate projects, in that I have developed one EXE project and WCF and I have done switching in debugging mode by attaching WCF project in process of debugging client of EXE and it has worked.
But when I transfer my WCF to servicestack then I could not able switch between them.
I am running my EXE project and and attached my WCF(servicestack) project to process
JsonServiceClient client = new JsonServiceClient("MYServiceURL");
RESTWCF.ServiceModel.Perfmon objBalPerformanceDataProperties = MakeObjectForServiceStackToInsertData();
var res = client.Post<RESTWCF.ServiceModel.Perfmon>("/perfmon", objBalPerformanceDataProperties);
When I click F11 on client.post I could not able to switch in WCF project, I think you can make sense of my problem.
Give me some solution of this problem so I can debug my code of WCF project (to find error :) in that)
Thanks.
You can only debug one host project at a time.
If you want to test the server set the ServiceStack project to be Start-up Host and press F5 to start debugging the ServiceStack host. Put a break-point at the start of the service you want to hit.
You can then just Run (i.e. without debugging) the client application which if everything is configured correctly, it should hit your breakpoint.
To make sure you're debugging the service correctly, instead of running the client first try calling the web service via a url, e.g:
http://localhost/MyServiceUrl/perfmon
If it hits the break-point you set, then all is well and you can run the client application as mentioned above.
Also it's a good idea to include ServiceStack's debbuging symbols, i.e. it's *.pdb files in the same folder as it's *.dll's - as it helps with debugging.
Note: WCF has nothing to do with ServiceStack - In a lot of cases that's considered an insult :-)

How to attach browser and my web Application

Dear All,
I am working on the Web application, at time of run the my application open login page but browser disconnect from my application. So I am not able to debug the code.
Please help how to stop this disconnectivity between browser and my web application.
Assuming you are using Visual Studio then all you need to do is put a breakpoint in a method that you know is going to be hit in order to debug the code i.e. your login forms page_load method.
A more fundamental point is that the client/web server model is stateless and that there will be no connection between your browser and the server between requests.
Ok, a few answers here depending on what you are doing. If you are using the built in web server in Visual Studio you simply have to set break points within your code. If on the other hand you are using IIS and Visual Studio in combination then all you need to do is set a break oint in your code and attach Visual Studio to the relevant w3svc worker process, if in doubt select them all.
It's something I do virtually every day and it works very well indeed.
simes

Don't start ASP.NET Development Server when running non-web projects

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.

How to run just one ASP.NET Development Server in Visual Studio 2008?

I have several web application projects in one solution.
When I start debugging one of those web applications I noticed that the ASP.NET Development Server starts for all web applications in my solution.
How can I determine to just one ASP.NET Development Server to be started?
Is this even possible?
I don't want to have my system tray filled with icons of all my web applications.
Thanks!
Duplicate: Why do VS2008 spawn one Cassini for each web-site/application when going into debug mode?
This might work for you, I have a similar issue since there are several web remoting projects in my solution. What I did was set up virtual directories for each in IIS then just right-click the each project and select properties. On the Web tab I then set the server to use when debugging to IIS. This causes Visual Studio to use the single instance of IIS instead of opening a dozen separate web development servers for each project. When you debug, attach to w3wp.exe processes.
As far as I am aware you can't stop this behaviour and is by design.
This because of the way that VS attaches its debugger to target processes. i.e. you couldn't have two instances of VS attaching to the same process. Hence multiple instances of the cassini web server, one for each VS session.

Resources