Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: DefaultRedirect Does Not Work When You Use SmartNavigation


View products that this article applies to.

Symptoms

When you design an ASP.NET Web page that uses SmartNavigation, you set the defaultRedirect property in the customErrors tag that appears in the Web.config file to redirect users to an error page if an error occurs. However, when an error occurs in the ASP.NET page during postback, users are not redirected to the error page. Instead, they receive the following error message in the ASP.NET page:
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.

↑ Back to the top


Cause

The defaultRedirect feature is not supported when SmartNavigation is turned on in an ASP.NET Web page.

↑ Back to the top


Workaround

To work around this problem, use one of the following methods:
  • Turn off the SmartNavigation feature.

    -or-
  • Set the ErrorPage in the @ Page directives as follows:
    1. Use the following code to add the ErrorPage page directive:
      <%@ Page smartNavigation="True"  ErrorPage="Error.aspx" %>
    2. Verify whether the customErrors message mode is set to On in the Web.config file as follows:
       <customErrors defaultRedirect = "Error.aspx"
          mode="On" 
          />

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

This problem occurs only when the ASP.NET Web page is posted back�for example, on the OnClick event of a button. The problem does not occur the first time that the page is loaded.

Steps to Reproduce the Behavior

  1. In Microsoft Visual Studio .NET, create a new ASP.NET Web Application project by using Visual C# .NET. By default, WebForm1.aspx is created.
  2. In Design View, right-click WebForm1.aspx.
  3. Click View HTML Source.
  4. Replace the existing HTML code in Webform1.aspx with the following code:
    <%@ Page language="c#" SmartNavigation = "true" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    	<HEAD>
    		<title>WebForm1</title>
    		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    		<meta name="CODE_LANGUAGE" Content="C#">
    		<meta name="vs_defaultClientScript" content="JavaScript">
    		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    	</HEAD>
    	<body MS_POSITIONING="GridLayout">
    		<script language =C# runat =server >
    			private void Button1_Click(object sender, System.EventArgs e)
    			{
    				throw new Exception("This is custom error for testing.");
    			}
    		</script> 
    		<form id="Form1" method="post" runat="server">
    			<asp:Button id="Button1" runat="server" Text="Button" OnClick = "Button1_Click">
    			</asp:Button>
    		</form>
    	</body>
    </HTML>
  5. Open the Web.config file in Notepad (or any other text editor), and then locate the following customErrors tag:
    <customErrors 
        mode="On" />
    Replace the customErrors line with the following line:
    <customErrors defaultRedirect = "Error.aspx"
        mode="On" />
  6. Add another WebForm to the project. Name the WebForm Error.aspx.
  7. Open the HTML View of the Error.aspx WebForm, and then replace the existing HTML code with the following code:
    <%@ Page language="c#" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html>
    	<head>
    		<title>WebForm2</title>
    		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    		<meta name="CODE_LANGUAGE" Content="C#">
    		<meta name="vs_defaultClientScript" content="JavaScript">
    		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    	</head>
    	<body MS_POSITIONING="GridLayout">
    		<form id="WebForm2" method="post" runat="server">
    		This is Error Page.
    		</form>
    	</body>
    </html>
  8. On the Debug menu, click Start to run the project.
  9. Click Button. The error message in the "Symptoms" section appears.

↑ Back to the top


Keywords: KB813831, kbbug, kbwebforms, kbservercontrols, kbconfig, kbevent, kberrmsg

↑ Back to the top

Article Info
Article ID : 813831
Revision : 6
Created on : 5/25/2007
Published on : 5/25/2007
Exists online : False
Views : 362