Microsoft KB Archive/813831

= BUG: DefaultRedirect Does Not Work When You Use SmartNavigation =

Article ID: 813831

Article Last Modified on 5/25/2007

-

APPLIES TO


 * Microsoft ASP.NET 1.0

-



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.



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



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:   Use the following code to add the ErrorPage page directive: <%@ Page smartNavigation=&quot;True&quot; ErrorPage=&quot;Error.aspx&quot; %>   Verify whether the customErrors message mode is set to On in the Web.config file as follows:   

<div class="status_section">

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

<div class="moreinformation_section">

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

<div class="references_section">