Unable to remote debug asp.net mvc core application on IIS8 (AWS EC2) - iis

I have an MVC core website written in C# which is deployed to an AWS EC2 Instance with Windows Server 2012 R2 and IIS8 deployed on it.
I am trying to remote debug the application as I am getting errors thrown which I don't when running locally (details for another post maybe).
On AWS Console, I have a security group with the following Rules as guided by here:
and when I click on Debug->Attach to process, and browse to my AWS instance, I can see the correct dnx.exe process, however, when I attach to that process,
I get the The breakpoint will not currently be hit. No symbols have been loaded for this document
I've tried going to Tools->Options->Debugging->Symbols and clicking Load all symbols as it is my understanding that since VS2012 the symbols do not need to be deployed, but rather just on the local machine doing the debugging, taken from here.
In versions of Visual Studio before VS 2012, debugging managed code on a remote device required that the symbol files were also located on the remote machine. This is no longer the case. All symbol files must be located on the local machine or in a location specified in the Debugging / Symbols page of the Visual Studio Options dialog box. See .NET Remote Symbol Loading Changes in Visual Studio 2012 and 2013 on the Microsoft Application Lifecycle blog.
I can see the connections being initiated in the MSVSMON process on the EC2 instance.
I feel like I'm close but I'm just missing one simple thing.

You need to check on which port the Remote Debugger is running and allow inbound traffic on that port by opening Inbound Port [4024 in my case] with a Custom TCP Rule for Remote Debugging.
You can check the port used by Remote Debugger at Tools > Options in the Remote Debugger Menu.

Related

Remote debug Azure web job with .NET 6 in Visual Studio 2022

I followed this tutorial to create a simple web job in Azure: https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started. The web job itself does its job, consumes the message in the queue and I see them appear in Application Insights.
However, I want to debug the function on my local machine by using the tools available in Visual Studio 2022.
I have published with following profile settings:
Next I've attached the debugger under het Hosting menu:
First thing I noticed is a message about no symbols being loaded when putting a breakpoint in the function:
When I add a message to my queue, it gets consumed by the web job but the breakpoint is never hit. I've been reading a lot of similar questions regarding a this issue but I'm not progressing any further.
In Azure Portal, I've enabled Remote debugging under Configuration > general settings
In Visual Studio 2022, I checked if the correct process is attached
Here I'm a bit confused thou, the connection target is connecting through port 4024, which is according to this document, the port for Visual Studio 2019. However, a connection target with port 4026 is not found.
What am I missing here? Am I forgetting another setting somewhere?
If have tried changing the stack setting .NET version from APS.NET V4.8 to NET 6 (LTS) but that didn't help.
Should the platform architecture match the architecture of my machine in order to get it to work? Or is this not linked in any way with the debugger?
Is there anything else that I should check or try? Because my hair is turning grey here :)
Apologies for the delay here!
It should be 4024 for both 32 and 64 bit.
See this Azure doc: Remote Debugger Ports on Microsoft Azure App Service
Typically, the error “The breakpoint will not currently be hit. No symbols have been loaded for this document.” -- This error message indicates we can start debug process and attach, but cannot set a breakpoint on any or some lines of code in the project.
Most, likely cause: Application is built without debug symbols or debug symbols are not available
Kindly try these steps:
Verify Debug Symbols are being used and published and in sync
Workaround the issue by disabling “Enable Just My Code” from the
Tools >> Options >> Debugging >> general menu in Visual Studio
Other things to narrow-down the issue:
Debug symbols must be available locally or deployed to the Azure App Service, and must match the local code you are trying to debug.
It is recommended to use Cloud Explorer over Server Explorer to
connect and debug which requires the Azure SDK.
You could optionally Manually Attach a Debugger to Azure Web Apps to troubleshoot this further or recommend this as a workaround.
(old blog, try similar steps)
Kindly verify the port (Visual Studio remote debugger port assignments ) required is open in the corporate firewall and on your local machine.
As a test, you may use tool like Wireshark/netmon, to see if the port successfully connects to the port (4024) needed by the process.

Visual Studio 20149 Remote debugger windows does not show Application pool and user names

I had a Windows 2008 Server which was being used as Application server that has recently been upgraded to Windows 2012 -> Windows Server 2016 -> Windows Server 2019.
All of the applications under IIS work, but one. I am trying to figure out what is wrong. I have installed Visual Studio 2019 Remote Debugging tool on the server and trying to attach to the erroneous project under IIS.
I have the Remote Debugger running
but when I try to attach to remote process the Application pool and user names do not show up in the "Attach to process" window.
Since I can not see the details I can not connect to my application and debug. I am sure that "Show processes from all users" is checked.
I know that if the application does not run on the server it does not show up in this list, but I have called other applications under the site which are running but they don't appear either.
Try run the remote debugger under the different user account:
You can stop the remote debugger and restart it with the account you are using on the local computer.
You can start the remote debugger from the command line with the /allow parameter: msvsmon /allow username#computer
You can add the user to the remote debugger's permissions (in the
remote debugger window, Tools > Permissions).
If you can't use the methods in the preceding steps, you can allow
any user to do remote debugging. In the remote debugger window, go to
the Tools > Options dialog. When you select No Authentication, you
can then check Allow any user to debug. However, you should use this
option only if you have no choice, or if you are on a private
network.

Can't debug in Visual Studio when using local IIS WITH hostname

I have a solution that contains multiple projects, two of which are web applications that have their own separate domains. I have this published successfully to my dev/production environment fine and now would like to mirror these settings across to my local machine for better testing.
I have configured the project to run under Local IIS and enter the required Url for both projects and hit debug, I'm then presented with the following error:
Unable to start debugging on the web server.
Invalid access to memory location.
Interestingly if I change my IIS configuration and remove the hostname and change the port to 81/82 (and reflect these changes in VS) then I can successfully start debugging my application.
This is more of an irritation than anything else as I can work without the custom hostnames and configure the rest of IIS perfectly, however this does get in the way of logging into both systems simultaneously.
I tried a number of recommended fixes such as:
Ensured app pool is running
Restarted Visual Studio
Restarted computer
Run VS as Administrator

Debug asp.net 5 application with specific domain

I want to run my ASP.NET 5 (beta7) application in Visual Studio 2015 on a specific domain, mydomain.com for example. How could it be achieved?
Hosting the published version would lose the Visual Studio debuging. Built in IISExpress launch profile do net let domain address change, just port number of localhost address.
EDIT: I've solved the problem with self-host, Microsoft.AspNet.Server.WebListener, but is there a way to do that with Windows IIS 8.5?
Publish your app to the file system and set up an IIS site as described in the documentation. You can use a custom domain if you override routing in the etc/hosts file.
In Visual Studio, go to Debug -> Attach to process
Check Show processes from all users
Find process called w3wp.exe and attach the debugger to it
Now your breakpoints will be hit as if hosted in IIS Express...
For me, I had to attach to the correct dnx.exe process not the w3wp.exe.
I found the correct dnx process by looking at the username it was running under. It was the app pool identity that I assigned the site to in IIS.
Update (2016-09-14):
With the release of .NET Core 1.0, I now must attach to a process that is named the same as my project. Eg. if my project is name TestWebApp then the process I attach to is named TestWebApp.exe.

Debugging multi-site web applications in Visual Studio on Windows 8.1

I have a multi site Azure based web application. One site contains the web pages (with the view functionality driven through jQuery, Raphaël, and HTML) and a thin WCF service. The second site contains a more functional WCF service which in turn calls the data objects that call the database. We stopped development on the site a few years ago but it is still live for the few people who still enjoy using it.
Yesterday I had to fix an cross-site scripting vulnerability someone had reported on the site.
I was alarmed to find that I can no longer run the sites on my local machine under Visual Studio to test and debug any changes before deploying them to Azure.
Because of the interaction between the two WCF sites I had the local debugging set up as follows:
In the Internet Information Services Manager tool (InetMgr) I add additional websites with their physical path set to the location of the source code in the TFS local path on my machine.
I edit the host name in the site's binding to mimic the Azure location, i.e. the main site is projname.cloudapp.net:80 on Azure and projnamelocal.cloudapp.net:80 in my local IIS and the data WCF site is projname-wcf.cloudapp.net:8080 on Azure and projname-wcflocal.cloudapp.net:8080 in my local IIS. (N.B. The main site has a HTTPS binding too.)
I edit C:\Windows\System32\drivers\etc\hosts to include the lines
127.0.0.1 projnamelocal.cloudapp.net
127.0.0.1 projname-wcflocal.cloudapp.net
In Visual Studio I edit the web properties for the main site's project so that it uses the local IIS and project URL http://projname.cloudapp.net/ and I have a switch (in the code to say whether to call the local WCF or the live Azure one.
In the past when the project was under active development this set-up worked fine for locally testing and debugging. Yesterday it failed, one one machine http://projnamelocal.cloudapp.net/ gave a 503 error on another a 404. (N.B. I can ping each URL from the command line so the hosts redirect is working.) Visual Studio complains that it is "unable to start debugging on the web server" and that it "could not start ASP.NET debugging".
I've tried all the suggestions and some:
Running without debugging
Running Visual Studio as administrator (I was already)
Re-registering ASP
Changing the app pool
Giving everyone full permissions to the code directory
Running as my own domain account that is an admin on the local machine
Changing IE to not auto-detect proxies
Adding the sites to IE's list of trusted sites
Turning off IE's protected mode
Restarting Visual Studio
Restarting the PC
Restarting the PC again
How should I set-up this style of running, testing, and debugging local sites work in IIS under Visual Studio?
Got it.
I had forgotten to go to Control Panel > Programs > Turn Windows features on or off > .Net Framework 4.5 Advanced Services > WCF Services > HTTP Activation
Now that I have that installed the local sites start

Resources