The ViewStateUserKey property needs to be set during Page_Init.

Stack trace:
at System.Web.UI.Page.set_ViewStateUserKey(String value)
at WOT.PortalControls.WOTAbstractWebPartEx.Page_Init(Object sender, EventArgs e) in D:GitTOW_0715SourceEdenredFi.WOTWebApp_CodesWOTAbstractWebPart.cs:line 711
at System.Web.UI.Control.OnInit(EventArgs e)
at CMS.Base.Web.UI.AbstractUserControl.OnInit(EventArgs e)
at CMS.PortalEngine.Web.UI.CMSAbstractWebPart.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at CMS.PortalEngine.Web.UI.CMSWebPartZone.LoadWebPart(Control container, CMSWebPartZone zone, WebPartInstance part, Boolean reloadData, Boolean isVariant)

// System.Web.UI.Page
/// <summary>Assigns an identifier to an individual user in the view-state variable associated with the current page.</summary>
/// <returns>The identifier for the individual user.</returns>
/// <exception cref="T:System.Web.HttpException">The <see cref="P:System.Web.UI.Page.ViewStateUserKey" /> property was accessed too late during page processing. </exception>
// Token: 0x1700093A RID: 2362
// (get) Token: 0x060020DC RID: 8412 RVA: 0x0006966A File Offset: 0x0006786A
// (set) Token: 0x060020DD RID: 8413 RVA: 0x00069672 File Offset: 0x00067872
[Browsable(false)]
public string ViewStateUserKey
{
    get
    {
        return this._viewStateUserKey;
    }
    set
    {
        if (base.ControlState >= ControlState.Initialized)
        {
            throw new HttpException(SR.GetString("Too_late_for_ViewStateUserKey"));
        }
        this._viewStateUserKey = value;
    }
}

System.Web.dll!System.Web.UI.Page.ViewStateUserKey.set(string value) Unknown
.Page_Init(object sender, System.EventArgs e) Line 711 C#
System.Web.dll!System.Web.UI.Control.OnInit(System.EventArgs e) Unknown
CMS.Base.Web.UI.dll!CMS.Base.Web.UI.AbstractUserControl.OnInit(System.EventArgs e) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSAbstractWebPart.OnInit(System.EventArgs e) Unknown
System.Web.dll!System.Web.UI.Control.InitRecursive(System.Web.UI.Control namingContainer) Unknown
System.Web.dll!System.Web.UI.Control.AddedControl(System.Web.UI.Control control, int index) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSWebPartZone.LoadWebPart(System.Web.UI.Control container, CMS.PortalEngine.Web.UI.CMSWebPartZone zone, CMS.PortalEngine.WebPartInstance part, bool reloadData, bool isVariant) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSWebPartZone.LoadWebParts(CMS.PortalEngine.WebPartZoneInstance zoneInstance, bool reloadData) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSAbstractLayout.LoadZone(CMS.PortalEngine.Web.UI.CMSWebPartZone zone, bool reloadData) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSAbstractLayout.LoadContent(CMS.DocumentEngine.PageInfo pageInfo, bool reloadData, bool allowOrphanedZones) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSPagePlaceholder.LoadContent(CMS.DocumentEngine.PageInfo pageInfo, bool reloadData) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSPagePlaceholder.LoadContent(CMS.DocumentEngine.PageInfo pageInfo, bool reloadData) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSPortalManager.LoadPage(bool reloadData) Unknown
CMS.PortalEngine.Web.UI.dll!CMS.PortalEngine.Web.UI.CMSPortalManager.PageHelper_InitComplete(object sender, System.EventArgs e) Unknown
CMS.Base.Web.UI.dll!CMS.Base.Web.UI.PageContext.CurrentPage_InitComplete(object sender, System.EventArgs e) Unknown
System.Web.dll!System.Web.UI.Page.OnInitComplete(System.EventArgs e) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest() Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) Unknown
App_Web_portaltemplate.aspx.67ab7734.ktj1niyq.dll!ASP.cmspages_portaltemplate_aspx.ProcessRequest(System.Web.HttpContext context) C#
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStepImpl(System.Web.HttpApplication.IExecutionStep step) Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously) Unknown
System.Web.dll!System.Web.HttpApplication.PipelineStepManager.ResumeSteps(System.Exception error) Unknown
System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context, System.AsyncCallback cb) Unknown
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr, System.Web.HttpContext context) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
[AppDomain Transition]

对比Kentico7和Kentico12可以发现,堆栈信息不同

原文地址:https://www.cnblogs.com/chucklu/p/15076101.html