469,134 Members | 1,290 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,134 developers. It's quick & easy.

Viewstate Errors

I have an ASP application that works fine locally but when it's uploaded occasionally, I get viewstate errors. Another thing is that the viewstate for that page is disabled. There are cases where I can just refresh the page and it goes through ok

<%@ Page Language="VB" EnableViewState="false" Debug="true" %

The worker threads are set to one, however, it is running on a dual processor web server. The Load Balancer is not installed. What else could it be

How can the page get an invalid viewstate if its is off? Here's the error message that I get

Error page

Server Error in '/Generic' Application
-------------------------------------------------------------------------------

The viewstate is invalid for this page and might be corrupted
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code

Exception Details: System.Web.HttpException: The viewstate is invalid for
this page and might be corrupted

Source Error

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below

Stack Trace

[HttpException (0x80004005): The viewstate is invalid for this page and
might be corrupted.
System.Web.UI.Page.LoadPageStateFromPersistenceMed ium() +15
System.Web.UI.Page.LoadPageViewState() +1
System.Web.UI.Page.ProcessRequestMain() +42

-------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.57

Here's the sourc

<%@ Page Language="VB" EnableViewState="false" Debug="true" %><%@ Register TagPrefix="GJ" TagName="Header" Src="aspx_pagelet/header.ascx" %><%@ Register TagPrefix="GJ" TagName="Menu" Src="aspx_pagelet/menu.ascx" %><%@ Register TagPrefix="GJ" TagName="Banners" Src="aspx_pagelet/banners.ascx" %><script runat="server"
dim LOGINSTATE as boolea
sub RECORDLOGIN(UID as string,CONNSTR as string
dim GJOleDBConnection As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(CONNSTR
dim GJCmd as System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand("update wbrg_users set lastlogin='" & now() & "' where userid='" & replace(UID,"'","''") & "'", GJOleDBConnection
GJOleDBConnection.open(
GJCmd.ExecuteNonQuery(
GJCmd.Connection.Close(
end su

sub LOGIN(sender As Object, e As EventArgs
Dim GJDataset As New System.Data.DataSe
Dim GJOleDBConnection As System.Data.OleDb.OleDbConnectio
Dim GJOleDbDataAdapter As System.Data.OleDb.OleDbDataAdapte
GJOleDBConnection = New System.Data.OleDb.OleDbConnection(ConfigurationSet tings.AppSettings("USR")
GJOleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter("select userid,comments,pwd from wbrg_users where userid='" & replace(FLD_UI.text,"'","''") & "'", GJOleDBConnection
GJOleDbDataAdapter.Fill(GJDataSet, "LOGINLIST"
GJOleDBConnection.Close(

LOGINSTATE=fals
dim GJDatatable as System.Data.datatabl
dim GJDatarow as System.Data.dataro
dim GJDatacolumn as System.Data.datacolum

for each GJDatatable in GJDataSet.Table
if GJDataTable.Tablename="LOGINLIST" the
for each GJDatarow in GJDatatable.row
if ucase(GJDatarow("pwd").tostring())=ucase(FLD_PS.te xt) the
LOGINSTATE=tru
session("USERID")=GJDatarow("userid").tostring(
RECORDLOGIN(session("USERID"),ConfigurationSetting s.AppSettings("USR")
if request.querystring("op")<>"" the
response.redirect("addtocartops.aspx?op=" & request.querystring("OP") & "&id=" & server.urlencode(request.querystring("id")) & "&st=" & request.querystring("st") & "&vn=" & request.querystring("vn") & "&qt=" & server.urlencode(request.querystring("qt"))
elseif request.querystring("id")<>"" the
response.redirect("addtocart.aspx?id=" & server.urlencode(request.querystring("id")) & "&st=" & request.querystring("st") & "&vn=" & request.querystring("vn") & "&qt=" & server.urlencode(request.querystring("qt"))
elseif request.querystring("pr")<>"" then
response.redirect("myprofile.aspx")
elseif request.querystring("cc")<>"" then
response.redirect("user_ccards.aspx")
elseif request.querystring("AR")<>"" then
response.redirect("user_addresses.aspx")
elseif request.querystring("CK")<>"" then
response.redirect("checkout.aspx")
elseif request.querystring("MO")<>"" then
response.redirect("myorders.aspx")
else
response.redirect("home.aspx")
end if
exit for
end if
next
if session("USERID")="" then
ResPanel.text="<div class=""FRM_MSG"">Log In failed. No records found matching your username and password combination."
ResPanel.text=ResPanel.text & "<br>Use the form below to sign into an existing account or <a href=""createaccount.aspx?id=" & server.urlencode(request.querystring("id")) & "&qt=" & server.urlencode(request.querystring("qt")) & """>click here to register.</a></div>"
end if
end if
next
end sub

Sub Page_Load(sender As Object, e As EventArgs)
if request.querystring("msg")="1" and ispostback=false then
ResPanel.text="<div class=""FRM_MSG"">This transaction requires you to sign in."
ResPanel.text=ResPanel.text & "<br>Use the form below to sign into an existing account or <a href=""createaccount.aspx?id=" & server.urlencode(request.querystring("id")) & "&qt=" & server.urlencode(request.querystring("qt")) & """>click here to register.</a></div>"
end if
End Sub
</script><html><head><title>EasyRiders - Log In</title><link rel="stylesheet" type="text/css" href="css/header.css" /><link rel="stylesheet" type="text/css" href="css/form.css" /><script src="javascript/header.js" language="javascript"></script></head><body><div style="position:absolute;width:100%;z-index:-1;top:200px;text-align:center;filter:fliph();"><img src="aspx_img/vtbike.jpg"></div><form runat="server" method="post"><center><GJ:Header runat="server"/><GJ:Menu runat="server"/><br><asp:label id="ResPanel" runat="server"></asp:label><table cellpadding="0" cellspacing="0" style="width:100%;"><tr><td style="padding-left:20px;padding-right:20px;vertical-align:top"><table class="FRM_CONTAINER" cellspacing="0" cellpadding="0"><tr><td class="FRM_HEADER" colspan="2">Sign In</td></tr><tr><td class="FRM_LABEL" nowrap>User ID: </td><td><asp:textbox class="FRM_ITEM" id="FLD_UI" runat="server" maxlength="255"></asp:textbox></td></tr><tr><td class="FRM_LABEL" nowrap>Password: </td><td><asp:textbox class="FRM_ITEM" id="FLD_PS" runat="server" maxlength="255" textmode="password"></asp:textbox></td></tr><tr><td class="FRM_BTNBAR" nowrap colspan="2" style="padding:10px;"><asp:Button id="BTN_REG" onclick="LOGIN" runat="server" Text="Log In"></asp:Button></td></tr></table></td><td style="vertical-align:top"><GJ:Banners runat="server" PID="LoginPage_01"/><GJ:Banners runat="server" PID="LoginPage_02"/></td></tr></table></center></form></body></html>
Nov 18 '05 #1
1 1783
Hi,

Even if you set ViewState to false your page will store page hash key.
to learn about it and how to workaround refer to :
http://weblogs.asp.net/ngur/archive/.../30/46731.aspx
and
http://weblogs.asp.net/ngur/archive/.../08/85876.aspx

page hash key is used by ASP.NET to ensure that viewstate data belongs
to the current page. you can get invalid viewsate error if :
1) you transfer request to other page.
2) request arrive to server in cluster that don't have same machinekey
as server that create page.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Janaka | last post: by
2 posts views Thread by Max Metral | last post: by
11 posts views Thread by Nad | last post: by
10 posts views Thread by Robert | last post: by
5 posts views Thread by Tarun Mistry | last post: by
1 post views Thread by Tarun Mistry | last post: by
1 post views Thread by scottrm | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.