Hello and thank you for the opportunity to post my questions. I am having a heck of a time with the Ajax UpdatePanel.
My problem is as follows:
Everything works fine until there is some period of inactivity by the user (typically 2-3 minutes) and then when the user attempts to edit a row they receive the following message:
Sys.WebForms.PageRequestMangerServerErrorException: An unkown error occured while processing the request on the server. The status code returned from the server was:500
I have tried using the code listed below with the UpdatePanel UpdateMode Property using values of Conditional and Always with the same result.
What am I missing here? Do I need to add additional code to handle ViewState issues associated with the UpdatePanel?
Any assistance would be greatly appreciated! Thank you.
CODE USED:
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="true"
CodeFile="Default.aspx.vb" Inherits="_Default"
buffer="true" enableSessionState="true"
enableViewState="true" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ajax Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" AutoGenerateEditButton="True" DataKeyNames="ID"
DataSourceID="SqlDataSource1" GridLines="None" PageSize="20">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
<asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
UpdateCommand="UPDATE [Master] SET [LastName] = @dotnet.itags.org.LastName, [FirstName] = @dotnet.itags.org.FirstName,
[Type] = @dotnet.itags.org.Type, [Class] = @dotnet.itags.org.Class, [Status] = @dotnet.itags.org.Status
WHERE [ID] = @dotnet.itags.org.original_ID AND [LastName] = @dotnet.itags.org.original_LastName AND
[FirstName] = @dotnet.itags.org.original_FirstName AND [Type] = @dotnet.itags.org.original_Type AND
[Class] = @dotnet.itags.org.original_Class AND [Status] = @dotnet.itags.org.original_Status">
<UpdateParameters>
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Type" Type="String" />
<asp:Parameter Name="Class" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_Type" Type="String" />
<asp:Parameter Name="original_Class" Type="String" />
<asp:Parameter Name="original_Status" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Try to set EnableEventValidation="false" in <%@. Page %> tag..
see results if it solves the problem...
Thank you for taking the time to respond to my question. Yes I did try that and no it did not work. I also tried EnableViewStateMac = False and other suggestions outlined in Microsoft's Knowledge Base Article # 829743 entitled "Troubleshooting the "View State is invalid" error with ASP.NET" with no success either.
I have tried searching the blogs and other sites of interest releated to Ajax. The only post which I have seen that comes the closest to addressing this issue ishttp://www.openjs.com/articles/ajax/session_timeout.php but it addresses generic Ajax and not the flavor supported by Microsoft.
Due to the fact that I am brand new to using Ajax of any kind, I tried posing on this site to attempt to find an anwser to this vexing problem.
Thank you again for taking the time to respond to my post.
Thanks...I read the article about session_timeout...
Have you tried any other solution...
Hello again. Yes, I have tried a number of things. One method that appears to work is putting a timer on the page and setting the tick for every 2 minutes or so. When the timer reaches the alarm point, it refreshes the page. The problem seems to go away. However, using this type of method could have serious performance issues if deployed accross a large number of sites and pages being hosting on the same server.
So there definately is a relationship with this problem and the viewstate. By causing the page to refresh it resets the viewstate. There must be some value caused by the async postback(s) that is offending the validation at the server a some later time. It could also be releated to the fact that the session on the server has expired and it can't find anything to refer to so it blows up.
I love being a developer but sometimes stuff like this just drives me nuts!
Any thoughts you would like to add?
Thanks for your interest in helping to solve this problem for me.
Hiwindyman42
This happens when the machineKey used to encrypt/decrypt the viewstate was changed, and more likely this will happen if you keep the page idle for a long time. To avoid this, you need to have a static machineKey.
Check this articlehttp://blog.g9th.com/2007/01/14/unable-to-validate-data-at-systemwebconfigurationmachinekeysectiongetdecodeddata.aspx
Let me know if you need more info.
You can also see this thread for more help:http://forums.asp.net/t/1115331.aspx
Thanks
Thanks Jin-Yu Yinfor providing the more details...
Thank you for your response! I appologize for the delay in responding but I wanted to fully test your suggestion before replying to your post. I am very pleased to report that your suggestion does in fact FULLY FIX THE PROBLEM! The only thing that is a little puzzling however is that one of the links you provided (The Experts) said that making the MACViewState value = False has the same effect as providing a static machine key. I had tried this ealier but it was unsuccessful.
Thank you both for taking the time to provide assistance. I hope to return the favor in kind sometime in the future.
No comments:
Post a Comment