Bug reports Found a bug? Post it here please.
Version 4.x > Bug reports > ViewState View modes: 
User avatar
Member
Member
stearnst-cwu - 4/27/2009 5:21:41 AM
   
ViewState
I tried to search for a solution but to no avail.
My viewstates are not saved for my User Controls.
I just installed Kentico and am using version 4.

Any help is appreciated.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/28/2009 7:54:45 AM
   
RE:ViewState
Hi,

Could you be more specific please?

What is the code of your controls? What is should do and what you want to achieve?
Where are you using these controls? Could you please post here some code examples with more detailed example?
Thank you.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
stearnst-cwu - 4/28/2009 2:41:10 PM
   
RE:ViewState
I was just using a simple
ViewState["variable"] = "test";

and trying to retrieve it after a postback.

However, I changed these to Cache and everything started working again.

However, now sometimes this error popups and I am no longer explicitly using viewstate. Nor am I using a Web Farm or cluster. I haven't looked too much at different solutions to this but I will have to try later.

[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +148
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +10956181
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +59
System.Web.UI.HiddenFieldPageStatePersister.Load() +10956280
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +11040040
System.Web.UI.Page.LoadAllState() +46
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11035559
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11035098
System.Web.UI.Page.ProcessRequest() +91
System.Web.UI.Page.ProcessRequest(HttpContext context) +240
ASP.cmspages_portaltemplate_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\kenticocms\6fdd8ad5\5744711\App_Web_5s060xoc.34.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

User avatar
Member
Member
stearnst-cwu - 4/28/2009 7:47:31 PM
   
RE:ViewState
I made a sample test control with a button and a label

public partial class CMSInlineControls_test : CMS.ExtendedControls.InlineUserControl
{
public string test="";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Cache["test"] = "test";

}
else
{
test= ((string)Cache["test"]);
}



Label1.Text = test;

}
protected void Button1_Click(object sender, EventArgs e)
{
}
}


This works on my machine but accessing the site from elsewhere this error happens.
I also tried adding:
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never">
but did not fix the issue.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/29/2009 8:18:19 AM
   
RE:ViewState
Hi,

Thank you for the details. If you are using full page caching, could you please try to turn it off? There are some problems in current version with it.

Best Regards,
Juraj Ondrus