EPM - Issues when debugging web applications with Visual Studio

EPM - Issues when debugging web applications with Visual Studio

117
Created On 11/10/26 11:02 AM - Last Modified 11/10/26 12:57 PM


Question


What are some issues when debugging web applications with Visual Studio?

Environment


EPM EPM Console

Answer


When Visual Studio starts the web debugging process, the user credentials are transferred via HTTP and the elevated parameters are lost. This causes the debug process to fail. Similar behavior can be found when a process is connected to a resource on the network – users token is created on the target non-elevated. This is how authentication via network works.
There are two workarounds for this issue. We can elevate devenv.exe and manually debug or configure IIS to run under the limited user context. In the second case, you will not need to elevate devenv.exe.
Method 1: Elevate devenve.exe
1. Create a policy to elevate devenv.exe (no other processes require elevation in this scenario)
2. Start Visual Studio
3. Start your Web Application manually - just open IE and navigate to the application URL
4. In Visual Studio select Debug -> Attach to Process from the menu and then select the aspnet_wp.exe process
5. Visual Studio attaches to the process and you can debug your Web Application


Method 2: Execute aspnet_wp.exe with same credentials as Devenv.exe
Note: The following steps should be performed when you have local administrative rights.
1. Grant the user access to IIS 6 metabase
a. Open a CMD Window
b. Navigate to: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 (or appropriate framework version)
c. Execute the following command: aspnet_regiis.exe -ga "dom\user"
Where user dom\user is the actual user name
2. Configure ASP.NET to Run Using the New Account.  This procedure edits machine.config to configure ASP.NET to run using the new account.
To configure ASP.NET to run using the new account:
a. Download aspnet_setreg.exe utility from Microsoft’s site. See "Download and run Aspnet_setreg.exe" section at: https://support.microsoft.com/en-us/kb/329290
b. Encrypt the username and password attributes by using aspnet_setreg.exe. To do this, type the following command at the command line:
aspnet_setreg.exe -k:SOFTWARE\MY_SECURE_APP\ASPNET -u:"yourdomainname\username"  -p:"password"
This command encrypts the username and password attributes, creates registry keys at any location that you specify, and then stores the attributes in those registry keys. This command also generates output that specifies how to change your Web.config or Machine.config file so that ASP.NET will use these keys to read that information from the registry.
Note: For more information on the aspnet_setreg.exe utility, see "How to use the ASP.NET utility to encrypt credentials and session state connection strings" (http://support.microsoft.com/kb/329290/).
c. Open machine.config using Microsoft Visual Studio® .NET or Notepad. Machine.config is located in the following folder:
%systemroot%\WINNT\Microsoft.NET\Framework\<versionNumber>\CONFIG
d. Find <processModel> element and add username and password attributes as follows:
<processModel userName="registry:HKLM\SOFTWARE\MY_SECURE_APP\ASPNET\ASPNET_SETREG,userName" password="registry:HKLM\SOFTWARE\MY_SECURE_APP\ASPNET\ASPNET_SETREG,password" .....>
e. Execute the following command from CMD: iisreset
For more information see http://msdn.microsoft.com/en-us/library/ff649223.aspx

Note: 
On Windows 7 you don’t have to manually edit config files. The same result can be achieved using GUI configuration. 
After the above steps have been completed Visual Studio can be started as a limited user and start debugging the Web Application. Elevation is not required. (Elevation of devenv.exe is required only if you want to debug applications not belonging to the limited user.)

 


Additional Information


Details

Q:

What are some issues when debugging web applications with Visual Studio?

A:

When Visual Studio starts the web debugging process, the user credentials are transferred via HTTP and the elevated parameters are lost. This causes the debug process to fail. Similar behavior can be found when a process is connected to a resource on the network – users token is created on the target non-elevated. This is how authentication via network works.

There are two workarounds for this issue. We can elevate devenv.exe and manually debug or configure IIS to run under the limited user context. In the second case, you will not need to elevate devenv.exe.

Method 1: Elevate devenve.exe

1. Create a policy to elevate devenv.exe (no other processes require elevation in this scenario)

2. Start Visual Studio

3. Start your Web Application manually - just open IE and navigate to the application URL

4. In Visual Studio select Debug -> Attach to Process from the menu and then select the aspnet_wp.exe process

5. Visual Studio attaches to the process and you can debug your Web Application

Method 2: Execute aspnet_wp.exe with same credentials as Devenv.exe

Note: The following steps should be performed when you have local administrative rights.

1. Grant the user access to IIS 6 metabase

a. Open a CMD Window

b. Navigate to: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 (or appropriate framework version)

c. Execute the following command: aspnet_regiis.exe -ga "dom\user"

Where user dom\user is the actual user name

2. Configure ASP.NET to Run Using the New Account.  This procedure edits machine.config to configure ASP.NET to run using the new account.

To configure ASP.NET to run using the new account:

a. Download aspnet_setreg.exe utility from Microsoft’s site. See "Download and run Aspnet_setreg.exe" section at: https://support.microsoft.com/en-us/kb/329290

b. Encrypt the username and password attributes by using aspnet_setreg.exe. To do this, type the following command at the command line:

aspnet_setreg.exe -k:SOFTWARE\MY_SECURE_APP\ASPNET -u:"yourdomainname\username"  -p:"password"

This command encrypts the username and password attributes, creates registry keys at any location that you specify, and then stores the attributes in those registry keys. This command also generates output that specifies how to change your Web.config or Machine.config file so that ASP.NET will use these keys to read that information from the registry.

Note: For more information on the aspnet_setreg.exe utility, see "How to use the ASP.NET utility to encrypt credentials and session state connection strings" (http://support.microsoft.com/kb/329290/).

c. Open machine.config using Microsoft Visual Studio® .NET or Notepad. Machine.config is located in the following folder:

%systemroot%\WINNT\Microsoft.NET\Framework\<versionNumber>\CONFIG

d. Find <processModel> element and add username and password attributes as follows:

<processModel userName="registry:HKLM\SOFTWARE\MY_SECURE_APP\ASPNET\ASPNET_SETREG,userName" password="registry:HKLM\SOFTWARE\MY_SECURE_APP\ASPNET\ASPNET_SETREG,password" .....>

e. Execute the following command from CMD: iisreset


For more information see http://msdn.microsoft.com/en-us/library/ff649223.aspx


Note: On Windows 7 you don’t have to manually edit config files. The same result can be achieved using GUI configuration. After the above steps have been completed Visual Studio can be started as a limited user and start debugging the Web Application. Elevation is not required. (Elevation of devenv.exe is required only if you want to debug applications not belonging to the limited user.)




Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj0000000k6JCAQ&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail