Share via


Exercise 3: Debug ASP.Net Applications on Server Core

Part 1: Deploying the remote debugger service

  1. The first thing you must do is deploy the remote debugger service onto your Server Core host machine. From the Win2K8R2Core machine, repeat the following commands as illustrated:

    mkdir c:\msvsmon xcopy \\10.0.0.1\SCRATCH\RemoteDebugger\*.* c:\msvsmon\*.* /S c:\msvsmon\x64\msvsmon.exe

  2. The x64 Visual Studio remote debugger service (msvsmon.exe) should now be listening for connections as illustrated (NOTE: You may also see a dialog asking which scope to enable firewall ports for the remote debugging monitor. Choose to open all ports at the subnet or global scope.):

    Figure 1

Part 2: Setting-up the Visual Studio Machine

  1. On the Win2K8R2Dev machine, create an empty Visual Studio solution to host your application. Then select the option to Add an Existing Web Site to the solution as illustrated:

    Figure 2

  2. When prompted to select the web site, don’t be tempted to select the Local IIS option, as we do not intend to debug the application with the local IIS service. Instead, select the File System option, and choose the folder that holds the ASP.NET application you wish to debug. In the screenshot below, the folder pointed by the red arrow is the folder that holds our sample ASP.NET application

    Note:
    The project will be at c:\SCRATCH\website on the Win2K8R2Dev machine.:

    Figure 3

  3. Once the project has been configured, it is just a matter of changing some of the default options from the project to make sure it connects to the remote Server Core install. The first task is to make sure that the Start Action is set to wait for an external application. This is done because, as you will see very soon, we will not be starting the application, but rather attaching to the remote process that is hosting the application:

    Figure 4

    Another option that must be configured is to select a custom server instead of the default Web Server. This is specified in the section below, and you must also specify the URL of the website you wish to debug on the remote server core install:

    Note:
    Use https://10.0.0.3/website instead of the path illustrated in the graphic below.

    Figure 5

  4. Once you are ready to debug your application, place the corresponding breakpoint within the project file default.cs.
  5. Load the web site by accessing the URL from the Win2K8R2Dev machine using Internet Explorer.

    Note:
    Nothing should happen at this point, you are merely loading the web site so that the web server process on the host machine will run.

  6. Switch over to Visual Studio and from the Debug menu, select the Attach to Process… option. From the dialog, select the type of code to debug or else you will run into problems trying to debug your code later on. From the Attach to: portion of the dialog, click the Select button and only select the debug managed code check-box as shown below:

    Figure 6

    Note:
    Failure to carry-out this step will cause the debugger to try to debug T-SQL later-on when you do not intend on doing so.

  7. You must now select the machine name from the Qualifier option. For instance, if your Server Core username is student1 and the name of your machine is Win2K8R2Core, you would select the following option:

    Figure 7

    The next step involves attaching to the w3wp.exe process from the list of available processes (you must select the option to show processes from all users in order to see this process). If the process still does not display, reload your web page using Internet Explorer and then switch back to the dialog and use the Refresh button. Once the process becomes available, select it and click the Attach button.It is now a matter of carrying out the necessary steps in your ASP.NET application to hit any of the breakpoints you set. Once this happens, the breakpoint will be highlighted and you will be remotely debugging your ASP.NET code from within Visual Studio:

    Figure 8