A page will error out with "Sys.WebForms.PageRequestManagerServerErrorException: An unkown error occurred while processing the request on the server. The status code returned from the server was: 12031" when an update panel is updating for the second update. In other words, the first AJAX-style page update works fine, but the second one causes this error.
I've narrowed down the problem to urlMappings in the web.config file. I'm using it to control role-based access. When the page name doesn't match the source page name, the error occurs. For example, this works:
<urlMappings>
<add url="~/folder/Default2.aspx" mappedUrl="~/Default2.aspx"/>
</urlMappings>
While this doesn't:
<urlMappings>
<add url="~/folder/edit.aspx" mappedUrl="~/Default2.aspx"/>
</urlMappings>
Here's a project showing an example of the error in action. Master page:
<%@dotnet.itags.org. Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<ajax:ScriptManager runat="server" ID="SM1" />
<div class="header">
Sweet header text.
</div>
<asp:HyperLink runat="server" ID="HL1" NavigateUrl="~/folder/edit.aspx" Text="Page doesn't really exist!" /><br />
<asp:HyperLink runat="server" ID="HL2" NavigateUrl="~/Default.aspx" Text="Default page." /><br />
<b>Content begins:<br /></b><br /><br />
<ajax:UpdatePanel runat="server" ID="upanel1">
<ContentTemplate>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />
</ContentTemplate>
</ajax:UpdatePanel>
<br /><b>Content ended.</b><br /><br /
</div>
</form>
</body>
</html>
Default.aspx:
<%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This page is ~/Default.aspx.
</asp:Content>
Default2.aspx:
<%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This page is ~/Default2.aspx.<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
<asp:ListItem Text="Show label one" Value="1" />
<asp:ListItem Text="Show label two" Value="2" />
</asp:DropDownList>
<br />
<asp:Label ID="Label1" runat="server" Text="Label one" Visible="false" />
<asp:Label ID="Label2" runat="server" Text="Label two" Visible="false" />
</asp:Content>
Default2.aspx.vb:
PartialClass Default2
Inherits System.Web.UI.PageProtected Sub DropDownList1_SelectedIndexChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles DropDownList1.SelectedIndexChanged
If DropDownList1.SelectedValue ="1"Then Label1.Visible =True Label2.Visible =False
Else Label1.Visible =False Label2.Visible =True
End If
End Sub
End Class
Make a folder called "folder" in the root of the project and add this to the web.config, under system.web:
<urlMappings>
<add url="~/folder/edit.aspx" mappedUrl="~/Default2.aspx"/>
</urlMappings>
To see the bug, fire up the project and click the "Page doesn't really exist" link. This will bring you to the mapped page. Change the dropdownlist's selection, notice the label change, then change the selection on the DDL again. You'll get the error I specified earlier. Fiddler shows the AJAX call attempting to read folder/Default2.aspx instead of the correct URL, causing a 404 and the callback to fail.
Any idea for a fix on this one? It can be worked around by keeping the page names consistent, but that doesn't fix the bug.
No comments:
Post a Comment