Debugging and Error Handeling
Debugging and Error Handeling
This problem can occur if there is some error in the web.config file. To resolve this check for the well-
For more details refer PRB: "Unable to Start Debugging" Error Message When You Send Debug HTTP Request
3.2 Why do I get the error message "Unable to start debugging on the
web server..." when I debug?
There is a possibility that there is no web.config file for the project or there is no Execute permission for the
project.
If the web.config file is missing, add one to the directory that contains the ASP.NET application. You can copy
one from the numerous samples applications available with the framework installation.
COMPILATION
defaultLanguage="c#"
debug="true"
/>
On the other hand, if your project already has a Web.config file, and the above section is set as specified,
follow these steps to set the Execute Permissions property for the project folder:
1. Start Internet Services Manager, and then click the project that you are trying to debug.
4. If None is selected in the Execute Permissions list, click Scripts only, and then click Apply
Debugger Users group on the Microsoft Internet Information Server (IIS) server. To add the appropriate user
to the Debugger Users group, follow these steps on the Web server:
1. From the Windows Start menu, point to Programs, point to Administrative Tools, and then click
Computer Management.
2. In the left pane, click to expand the Computer Management, System Tools, and Local Users and
Groups nodes.
5. In the Select Users or Groups dialog box, select the appropriate user, and then click OK.
account) is not assigned the "Impersonate a client after authentication" user right in the "Local Security
Policy" settings. This issue may occur when you install Microsoft Visual Studio .NET after you install Windows
2000 Service Pack 4 (SP4) on the computer. In this situation, the ASPNET account is not assigned the
"Impersonate a client after authentication" user right in the "Local Security Policy" settings.To resolve it,
please use the method at: To work around the problem, manually assign Impersonate a client after
1. Click Start, point to Programs, point to Administrative Tools, and then click Domain Controller
Security Policy.
5. In the Security Policy Setting window, click Define these policy settings.
7. In the Select Users or Groups window, select the IWAM account name, click Add, and then click OK.
9. To enforce an update of computer policy, type the following command: secedit /refreshpolicy
machine_policy /enforce
10. At a command prompt, type iisreset. In case your server is a Domain Controller Refer PRB:
"Catastrophic Failure" Error Message When You Try to Debug an ASP.NET Application on Windows
Select the Configuration Properties for debugging then in right Pane, under the debugger node select true for
1. Open up the project's properties window and set the "Enable ASP.NET Debugging" option.
2. Open up your web.config file and make sure the Compilation tag's debug attribute is set to true.
3. Make sure the account you are logged in as and the ASP.NET Worker process is in the local
• PRB: Visual Studio .NET Debugger Does Not Stop on Breakpoints When You Debug ASP.NET Pages
• INFO: Common Errors When You Debug ASP.NET Applications in Visual Studio .NET
3.7 Why do I get error message "Unable to start debugging on the web
server. The debugger is not properly installed. Run setup to install or
repair the debugger. Would you like to disable future attempts to debug
ASP.NET pages for this project ? "?
If someone has run a lockdown or other security tool on the Web server, the DEBUG method may have been
removed.
Go into IIS manager to the Web application's properties and Directory >Configuration (button) > Mappings >
Application mappings.
Of course you need to be a member of the Debuggers group on the remote server. To resolve error
1. Right-click the Project Name in Solution Explorer, and then click Properties.
4. In the right pane, change the value of Enable Unmanged Debugging to True (on the drop-down list).
For more details refer PRB: Error Message: Unable to Start Debugging. Unable to Start Program ...
2) In VS.Net in your project properties dialog, select "Debugging" under "Configuration Properties" and make
3) You can then set break points in script code in VS.Net in custom script files or the application aspx file.
4) VS.Net should give you detailed debugging information for variables in the scope just like other high-level
languages.
• Using the Error event procedures at the Page, Application or Global levels
3.10 Why do I get error message "Login failed for user '(null)'. Reason:
Not associated with a trusted SQL Server connection"?
This error usually indicates that SQLServer (or MSDE) is configured to use Windows Authentication. If you
want to use a SQL login, you will need to enable SQL Authentication (mixed mode authentication). For more
details refer PRB: ASP/ODBC/SQL Server Error 0x80040E4D "Login Failed for User '(Null)'"
It means that the server is out of available memory. You probably have an infinite loop somewhere that's
frantically creating large objects, or you forgot to dispose of disposable objects and memory slowly leaked.
3.12 Why do I get the error message "Sql Server does not exists or
access denied " whenever I try to access the data on Sql server?
• The ASP.NET worker process doesn't have the correct permissions to connect to or write to the SQL
Server database. Either enable impersonation for users, or configure the ASP.NET worker process to
• The ASPNET account cannot establish a named pipes connection to the database server. Try using
TCP/IP instead of the Named Pipes protocol to connect to the database by adding "Network Library
• BUG: Named pipes do not work when worker process runs under ASPNET account
The ASPNET worker process doesn't have the correct permissions to connect to or write to the Access
database.
Either enable impersonation for users or configure the ASP.NET worker process to run under the SYSTEM
account. You can also grant read and write permissions for the "Everyone" group on the database and the
database folder.
3.14 Why do I get the "HTTP 404 - File not found." error message as
"The page cannot be found.The page you are looking for might have been
removed, had its name changed, or is temporarily unavailable "?
The reason for this error can be
• The requested file has been moved to another location and/or deleted.
• The requested file is temporarily unavailable due to maintenance, upgrades, or other unknown
causes.
• IIS 6.0: The appropriate Web service extension or MIME type is not enabled.
To resolve this refer Common reasons IIS Server returns "HTTP 404 - File not found" error
3.15 When I install the Microsoft .NET Framework 1.1 on a computer that
is running Windows XP, and then you start Windows, the Welcome
screen appears. This screen prompts me to click your user name to start
Windows.Why?
When you install the .NET Framework 1.1, a hidden local user account that is named ASPNET is created.
When you start Windows, Windows treats the ASPNET local user account as an additional user account,
although the ASPNET user account is hidden. Therefore, the Welcome screen appears and prompts you to
This problem occurs because of some antivirus applications write back information to the files that they scan.
Every time a user changes the Web.config configuration file, the Global.asax file, or the contents of the Bin
folder, the application should restart to incorporate these changes. Because antivirus scanning changes
cannot be distinguished from the user's file changes, the application restarts when the antivirus software
Note This problem may occur even when no error is returned. If the virus-scanning software triggers change
notifications, every change notification is doubled at the very least: one real change notification and an
additional change notification from the antivirus software some time later. For more information refer PRB:
You can view the page on which trace is enabled to true to see the details.
<configuration>
<system.web>
<trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime"
localOnly="true" />
</system.web>
</configuration>
3.18 I have installed ASP.NET hotfix and I find that Startup Type of the
ASP.NET Session State Service is set to Manual.Why?
Microsoft has acknowledged this as a Bug
3. Expand the Name column so that the complete name of each service appears.
Note A Startup Type column displays the current Startup Type value for each service.
4. Double-click the ASP.NET State Service service. The ASP.NET State Service Properties window
appears.
5. On the General tab, click one of the following options in the Startup type list:
o Manual
o Automatic
o Disabled
In the Services window, notice your changes to the Startup Type in the Startup Type column.
3.19 Why do I get the error message "aspnet_wp.exe (PID: XXXX) was
recycled because it was suspected to be in a deadlocked state "?
This problem might occur because ASP.NET limits the number of worker threads and completion port threads
that a call can use to execute requests. For more details refer PRB: Contention, poor performance, and
deadlocks when you make Web service requests from ASP.NET applications
VB.NET
C#
//In InitializeComponent
this.Error += new System.EventHandler (this.Page_Error );
//
private void Page_Error(object sender, System.EventArgs e )
{
Response.Write(Server.GetLastError().ToString());
Server.ClearError ();
}
In the Same manner handle the Errors in the Application_Error event in global.asax
3.21 How to redirect the user to the friendly error-handler page when an
Application error occurs?
Modify web.config as
The configuration section supports an inner <error> tag that associates HTTP status codes with custom error
• If ICF is in Shielded mode, you will need to perform appropriate actions so that it is no longer in
Shielded mode.
• If ICF is on, a few ports need to be opened and permissions must be granted to Microsoft® Visual
Studio® and other executables that are involved in the remote debugging.
• In addition, if the user running Visual Studio is not an Administrator on the remote machine, DCOM
The actual problem is because of the Microsoft Indexing Services which scans the Temporary ASP.NET Files
and while doing so, the system puts a lock on the same.
2. Expand the services and applications node and select the Indexing service node.
3. Expand the Indexing Service Node and then select and expand the System Node.
4. Right click on Directories and select new directory. browse the path to the temporary asp.net files
c:\winnt\microsoft.net\framework\v1.1.4322\.
5. Select the temporary asp.net files. give ok and then select the "NO" in the Include in index
radiobutton.
called request validation. Request validation looks at every request and determines if it could be a possible
CSS (Cross Site Scripting) attack. By default Request Validation is on for every page.
If you wish to allow users to post arbitrary HTML to you site you need to turn off request validation:
For more information check out : Protecting Against Script Exploits in a Web Application on MSDN
One approach is to use the Microsoft Web Application Stress tool. It allows you to simulate load on a web
server and can be used to test performance. The following kb article covers how to use it (including where to
3.26 How can I resolve the error message "Cannot access file '...'
because it is being used by another process"?
You receive this error message if the following conditions are true:
• The assembly that is specified in the error message is a signed assembly and is not installed in the
Global Assembly Cache (GAC); instead, the assembly is in the Bin directory of the ASP.NET Web
application. -and-
For more details refer PRB: "Can not Access File 'AssemblyName' Because It Is Being Used by Another
Process" Error Message in ASP.NET
3.27 Why do I get the Compiler Error Message: "CS0246: The type or
namespace name '...' could not be found (are you missing a using
directive or an assembly reference?) "?
• You add the class later on and run the project without compiling
• You have the class but you do not specify the namespace via Imports or using keyword
3.28 Why do I get the error message "Compiler Error Message: CS1595"?
This problem occurs because the C# compiler does not have permission to access the folders in the path to
To resolve this problem, modify the compiler definition for the C# compiler to include the /nostdlib option.
The /nostdlib option prevents the import of the mscorlib.dll assembly, which defines the entire System
namespace. To include the /nostdlib option in the C# compiler definition on a computer, follow these steps:
2. In the definition for C#, add the compilerOptions attribute with a value of /nostdlib. For example:
<compiler language="c#;cs;csharp"
extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider, System,
Version=1.0.3300.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089"
warningLevel="1"
compilerOptions="/nostdlib" />
For more details refer PRB: "Compiler Error Message: CS1595" Error Message When You Use the C# Compiler
3.29 I get error message at runtime "Value null was found where an
instance of an object was required" when using Application state
variables. why?
Application State variables must be initialized in C# before any operation is performed on them. For
example.:
You need to assign value to Counter state variable before performing the case (int)Session["Counter"].
3.30 I installed Windows 2003 Standard Edition, then VS.NET and SQL
Server 2K with SP3. When I build web project connecting to the database
in VS.NET, the compliler gives me the following error:Login failed for
user 'NT AUTHORITY\NETWORK SERVICE',why?
Add NT AUTHORITY\NETWORK SERVICE account to SQL Server , which will be in the local group. Make sure
VB.NET
Response.Redirect(url,false)
C#
Response.Redirect(url,false) ;
Its basically a syntax error in your ASPX page. It happens when your page is unreadable for the part of
IIS does not have the correct mapping for the ASPX file extension. This can happen if you install IIS after
To repair IIS mappings for ASP.NET, you can run the Aspnet_regiis.exe utility.
You get this error when you have not imported the following namespaces in your code in the aspx file:
System.Data.SqlClient or System.Data.OleDb.
3.36 Why do I get the Error message "Operation must use an updateable
query"?
If you're getting an error when Inserting or Updating an MS Access Database ('Operation must use an
updateable query'), that's because the ASPNet user account needs the correct permissions on the directory
• (Go into Accessories/Computer Management/Local Users & Groups/users You will see that there's an
ASPNet user. )
• Right click on the directory where your database is - choose properties - Then the security tab - then
click on permissions.
3.37 When compiling I get "Could not copy temporary files to the output
directory" or "The process cannot access the file because it is being used
by another process" error messages. Why?
Visual Studio .NET is unable to copy your DLLs from Bin directory to a temporary ASP.NET files folder. This is
due to having a trailing backslash in root web application, or in a virtual directory with child directories
permissions" permissions to detect file changes in Web.Config, Machine.config, Bin files, or Cach
dependency files.
2. Or one of the directory names in the hierarchy of that file path is greater than eight characters long.
• PRB: "Failed to Start Monitoring Directory Changes" Error Message When You Browse to ASP.NET
Page
• FIX: "Failed to start monitoring directory changes" error message when you browse to an ASP.NET
page
You may get this error if you have not give runat=server for a tag
3.40 How to see the Message in the Output window using ASP.NET?
VB.NET
System.Diagnostics.Trace.Write("Your message")
C#
System.Diagnostics.Trace.Write("Your message");
In Custom Components, you can use tracing if you reference the System.Web namespace and use the
VB.NET
System.Web.HttpContext.Current.Trace("xxx", "Message")
C#
System.Web.HttpContext.Current.Trace("xxx", "Message");
Also make sure to set the following directives:
<configuration>
<system.web>
<trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime"
localOnly="true" />
</system.web>
</configuration>