Live Chat Icon For mobile
Live Chat Icon

ASP.NET FAQ - Error Handling

Find answers for the most frequently asked questions
Expand All Collapse All

To enable remote debugging on Microsoft® Windows® XP SP2 platforms, the Internet Connection Firewall (ICF) must be configured as follows:

  • 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.
  • If IFC is off, no firewall configuration is necessary.
  • In addition, if the user running Visual Studio is not an Administrator on the remote machine, DCOM settings need to be configured.

Refer How to Enable Remote Debugging on Windows XP Service Pack 2

Permalink

This issue occurs if the account that is used to run the ASP.NET Worker process (by default, the ASPNET user 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 authentication to the IWAM account. To do so, follow these steps:

  1. Click Start, point to Programs, point to Administrative Tools, and then click Domain Controller Security Policy.
  2. Click Security Settings.
  3. Click Local Policies, and then click User Rights Assignment.
  4. In the right pane, double-click Impersonate a client after authentication.
  5. In the Security Policy Setting window, click Define these policy settings.
  6. Click Add, and then click Browse.
  7. In the Select Users or Groups window, select the IWAM account name, click Add, and then click OK.
  8. Click OK, and then click OK again.
  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 2000 Domain Controller
Permalink
  • 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 run under the SYSTEM account.
  • 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 =dbmssocn’ in your connection string

For more information refer

Permalink

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 download it from).

Permalink

Microsoft has acknowledged this as a Bug
To set the StartUp Type as desired refer following steps

  1. In Control Panel, open Administrative Tools.
  2. Click Services. The Services window appears.
  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:
    • Manual
    • Automatic
    • Disabled
  6. Click Apply, and then click OK to save your settings.

    In the Services window, notice your changes to the Startup Type in the Startup Type column.

Permalink
  1. The ASPNET worker process doesn’t have ‘Read & Execute’, ‘ List Folder Contents’, ‘ Read permissions’ permissions to detect file changes in Web.Config, Machine.config, Bin files, or Cache dependency files.
  2. Or one of the directory names in the hierarchy of that file path is greater than eight characters long.

For more information refer

Permalink

This problem occurs because the C# compiler does not have permission to access the folders in the path to the mscorlib.dll assembly

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:

  1. Open the Machine.config file, and then locate the section.
  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 to Compile an ASP.NET Resource

Permalink

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-
  • Your ASP.NET Web application has just been restarted.

For more details refer PRB: ‘Can not Access File ’AssemblyName’ Because It Is Being Used by Another Process’ Error Message in ASP.NET

Permalink

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

You could control the deadlock detection by changing machine.config setting in


<processModel responseDeadlockInterval='...'  ... />
Permalink

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 scans these folders.

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: Random application restarts with ‘Application is restarting’ error in ASP.NET

Permalink

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 click your user name.

For more details refer KB 827072

Permalink

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.

For more details refer

Permalink

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.
Check that for .aspx extensions, you allow GET,HEAD,POST,DEBUG

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.
  2. In the left pane of Properties, click to select Configuration Properties.
  3. Click to select Debugging.
  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 …

Permalink

Your ASP.NET project is not setup for debugging.

  • Open up the project’s properties window and set the “Enable ASP.NET Debugging” option.
  • Open up your web.config file and make sure the Compilation tag’s debug attribute is set to true.
<compilation defaultLanguage="vb" debug="true" />

Make sure the account you are logged in as and the ASP.NET Worker process is in the local “Debugger Users” group.

Permalink

We can set SetFocusOnError=’true’ for the ASP.NET validators, So that the first control with the validation error will receive the default focus when the form is submitted.

First Name:
<asp:TextBox ID=’TextBox1′ runat=’server’></asp:TextBox>
<asp:RequiredFieldValidator SetFocusOnError=’true’ ErrorMessage=’TextBox1 is empty’
ID=’RequiredFieldValidator1′ ControlToValidate=’TextBox1′ Display=’Dynamic’ runat=’server’>*
</asp:RequiredFieldValidator>
Last Name:
<asp:TextBox ID=’TextBox2′ runat=’server’></asp:TextBox>
<asp:RequiredFieldValidator SetFocusOnError=’true’ ErrorMessage=’TextBox2 is empty’
ID=’RequiredFieldValidator2′ ControlToValidate=’TextBox2′ Display=’Dynamic’ runat=’server’>*
</asp:RequiredFieldValidator>
Here SetFocusOnError is set to true for the validation control, so that the TextBoxes gets focused when it is empty.

Permalink

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.

To resolve this, the following steps need to be carried out:-

  1. Start – Settings – Control Panel – Administrative Tools – Computer management.
  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.
  6. give ok and then stop and start the indexing service.
Permalink

In Custom Components, you can use tracing if you reference the System.Web namespace and use the HttpContext.Current object to get a reference to the current context.

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:

For Page Level Tracing set Page Directive as

<%@ Page Trace='true' %>

For Application Level Tracing modify corresponding web.config as

<configuration>
    <system.web>
        <trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
    </system.web>
</configuration>
Permalink

For Page Level Tracing specify the Page Directive as


<%@ Page Trace='true' %>

You can view the page on which trace is enabled to true to see the details.

For Application Level Tracing modify web.config as


<configuration>
	<system.web>
     		<trace enabled='true' requestLimit='10' pageOutput='false' traceMode='SortByTime' localOnly='true' />
	</system.web>
</configuration>

You can view the Trace at http://<server>/<webApplicationName>/trace.axd

Permalink

Modify web.config as


<customErrors mode='On' defaultRedirect='errorpage.aspx' />

The <customErrors> configuration section supports an inner <error> tag that associates HTTP status codes with custom error pages. For example:


<customErrors mode='On' defaultRedirect='genericerror.htm'>
	<error statusCode='404' redirect='pagenotfound.aspx'/>
	<error statusCode='403' redirect='noaccess.aspx'/>
</customErrors>

For more details refer <customErrors> Element

Permalink

Sounds like you are running version 1.1 of ASP.NET / .NET Framework, which added a new security feature 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:


<%@Page ValidateRequest='false' %> 

For more information check out : Protecting Against Script Exploits in a Web Application on MSDN

Permalink

There is a possibility that there is no web.config file for the project or there is no Execute permission for the project.

If you already have a web.config file, double check it’s well-formedness.

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.

Make sure that the following section reads like this:


    <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.
  2. Right-click the project, and then click Properties.
  3. Click the Directory tab.
  4. If None is selected in the Execute Permissions list, click Scripts only, and then click Apply
Permalink

You would get this error if the application mappings for ASP.NET file name extensions (such as .aspx) are not configured correctly in Microsoft Internet Information Services (IIS).

To resolve this go to C:\Windows Directory\Microsoft.Net\Framework\Version and type aspnet_regiis -i to configure the required application mappings correctly

On Trying to Debug an application, by the F5 key I get the error: ‘Error while trying to run project: Unable to start debugging on the web server. Catastrophic failure’?

This issue occurs if the account that is used to run the ASP.NET Worker process (by default, the ASPNET user 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 authentication to the IWAM account. To do so, follow these steps:

  1. Click Start, point to Programs, point to Administrative Tools, and then click Domain Controller Security Policy.
  2. Click Security Settings.
  3. Click Local Policies, and then click User Rights Assignment.
  4. In the right pane, double-click Impersonate a client after authentication.
  5. In the Security Policy Setting window, click Define these policy settings.
  6. Click Add, and then click Browse.
  7. In the Select Users or Groups window, select the IWAM account name, click Add, and then click OK.
  8. Click OK, and then click OK again.

To enforce an update of computer policy, type the following command: secedit /refreshpolicy machine_policy /enforce

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 2000 Domain Controller

Permalink

Its basically a syntax error in your ASPX page. It happens when your code is inconvertible for the part of ASP.NET that transforms your code into an executable.

Permalink

1) In IE go to Tools/Internet Options…/Advanced Tab and clear the ‘Disable Script Debugging’ check box options.

2) In VS.Net in your project properties dialog, select ‘Debugging’ under ‘Configuration Properties’ and make sure that ‘Enable ASP.Net Debugging’ is turned on.

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.

Permalink

VB.NET


Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Error
        	Response.Write(Server.GetLastError().ToString)
        	Server.ClearError()
End Sub

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

Permalink

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 where the database resides
To fix this in Windows 2K:

  • (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.
  • Add the ASPNet user to the shared section
  • Then, make sure it has ’Change’ rights –
  • Click Apply and you should be working fine then.
Permalink

You can get this error if you are user who is trying to remotely debug and you are not a member of the 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.
  3. Click Groups, and then double-click Debugger Users.
  4. In the Debugger Users Properties dialog box, click Add.
  5. In the Select Users or Groups dialog box, select the appropriate user, and then click OK.
  6. Click OK to exit the Debugger Users Properties dialog box.
  7. Close the Computer Management explorer.
Permalink

Share with

Couldn't find the FAQs you're looking for?

Please submit your question and answer.