UpdatePanel PostBack Truncates HTTP Body

plt_almdr

New Member
When a postback in an update panel occurs too quickly, it seems that the ASP.NET client side JavaScript has a bug where the body it sends to the server does not equal the content-length in the HTTP header. This causes IIS 7.5 to throw an "invalid base-64" exception (for my particular app) when the view state variable gets truncated. A Fiddler trace shows that the HTTP request is in fact malformed.In my production cases (it happens on more than one page), it's due to very large view state. Yes, I can trim that or get rid of it altogether. But the question is does anyone know why the client truncates the body and how to avoid it?Given that I've added none of my own JavaScript, it seems to me that fault lies in the MS client-side JavaScript. Note that I've only triggered it in IE8/9 and Chrome and not Firefox -- maybe Firefox uses a different socket library (nspr still)?Following is an example that I've contrived to illustrate the problem. I added the page in a "Web Site" and am using VS10 with .Net 4. I can trigger the issue using IIS7.5 and the VS10 builtin web server. This example usually truncates at 64k (exactly) but my production pages vary.In Default.aspx:\[code\]<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="lblResult" runat="server" /> <asp:Repeater ID="rptCheckBoxes" runat="server"> <ItemTemplate> <br /> <asp:CheckBox ID="cbOne" runat="server" AutoPostBack="true" OnCheckedChanged="cb_OnCheckChanged" Text='<%# Eval("thing") %>' /> </ItemTemplate> </asp:Repeater> </ContentTemplate> </asp:UpdatePanel>\[/code\]In Default.aspx.cs:\[code\]protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { var things = new List<Thingy>(); for (int i = 0; i < 5000; i++) { things.Add(new Thingy { Thing = i.ToString() }); } rptCheckBoxes.DataSource = things; rptCheckBoxes.DataBind(); } } protected void cb_OnCheckChanged(object sender, EventArgs e) { CheckBox cb = sender as CheckBox; if (cb.Checked) { lblResult.Text = cb.Text; } else { lblResult.Text = "not checked"; } } internal class Thingy { public string Thing { get; set; } }\[/code\]Run Fiddler, rapidly click on checkboxes and eventually it shows a malformed HTTP request.
 
Back
Top