+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Problem with 'Login/Log out button' and custom MVC Widget

Problem with 'Login/Log out button' and custom MVC Widget

4 posts, 1 answered
  1. Stephan
    Stephan avatar
    7 posts
    Registered:
    05 Nov 2012
    01 Oct 2013
    Link to this post
    I am running Sitefinity 6.0.4200.0 SE and am having trouble when I have a 'Login/Log out button' and a custom MVC widget on the same page.

    The following does work:

    1. Page with only the 'Login/Log out button'
    2. I can click the 'Log in' link, which takes me to the standard Sitefinity Login page (~/sitefinity/Authenticate/SWT?...).
    3. I can log in with my credentials.
    4. I go back to the first page.
    5. I can click the 'Log out' link
    6. I am logged out as expected.

    The following does not work:

    1. Page with both the 'Login/Log out button' and my custom MVC widget.
    2. I can click the 'Log in' link, which takes me to the standard Sitefinity Login page (~/sitefinity/Authenticate/SWT?...).
    3. I can log in with my credentials.
    4. I go back to the first page.
    5. When I click the 'Log out' link, I get the following error:
    Server Error in '/' Application.
    --------------------------------------------------------------------------------
    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.
    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: 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.
     
    Source Error:
    [No relevant source lines]
     
    Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\64175248\4515be59\App_Web_59782c1a-51ae-69f1-bce4-ff0000a26cf3_130t083585490_basic.aspx.d63928b6.utw2q0l4.0.cs    Line: 0
     
    Stack Trace:
    [ViewStateException: Invalid viewstate.
        Client IP: ::1
        Port:
        Referer: http://localhost:60876/
        Path: /default.aspx
        User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
        ViewState: /wEPDwUKMTYxMjU1NjE5N2QYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgMFMEMwMDQkY3RsMDAkY3RsMDAkc2l0ZU1hcENvbnRyb2xfaG9yaXpvbnRhbHNpbXBsZQUjQzAwMyRjdGwwMCRjdGwwMCRyZW1lbWJlck1lQ2hlY2tib3gFH2N0bDE1JGN0bDAwJGN0bDAwJHdpbmRvd01hbmFnZXIHkDtaJYnZxJJozbOGHHUCfSbf7GDhCzqzLizgraxH7w==]
     
    [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) +198
       System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +432
       System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose) +8
       System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +40
       System.Web.UI.HiddenFieldPageStatePersister.Load() +248
       System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +88
       System.Web.UI.Page.LoadAllState() +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
       System.Web.UI.Page.ProcessRequest() +72
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
       System.Web.UI.Page.ProcessRequest(HttpContext context) +58
       System.Web.Mvc.OutputCacheAttribute.OnResultExecuting(ResultExecutingContext filterContext) +88
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +41
       System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
       Telerik.Sitefinity.Mvc.ControllerWrapper.Execute() +133
       Telerik.Sitefinity.Mvc.Proxy.MvcControllerProxy.ExecuteController() +4042
       Telerik.Sitefinity.Mvc.Proxy.MvcControllerProxy.OnPreRender(EventArgs e) +45
       System.Web.UI.Control.PreRenderRecursiveInternal() +83
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Control.PreRenderRecursiveInternal() +168
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
       System.Web.UI.Page.ProcessRequest() +72
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
       System.Web.UI.Page.ProcessRequest(HttpContext context) +58
       ASP.sfpageservice_59782c1a_51ae_69f1_bce4_ff0000a26cf3_130t083585490_basic_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\64175248\4515be59\App_Web_59782c1a-51ae-69f1-bce4-ff0000a26cf3_130t083585490_basic.aspx.d63928b6.utw2q0l4.0.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
      
    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

    My custom MVC isn't doing anything too special - it just accepts a few parameters, and appends those together into a string to insert a HTML iFrame tag onto the page.

    Has anyone else come across this error, or know how to fix/avoid it?

    Thanks in advance
     - Stephan
  2. mikem
    mikem avatar
    3 posts
    Registered:
    31 Jan 2007
    03 Oct 2013
    Link to this post
    I have contacted Telerik Support about this issue, and I have been provided with a solution that I wanted to share in case anyone else comes across the same issue.

    Within my MVC > Controller > .CS file I had the following line:
    OutputCache(NoStore = true, Duration = 0, VaryByParam = "*"),
    Removing this line also removed the error that I was seeing.

    I'm not sure if it is best just to remove this line, or if it would be better to leave it in there but change the values.  For now, removing it is working for me, and I will investigate the other settings as time permits.
    Answered
  3. Stephan
    Stephan avatar
    7 posts
    Registered:
    05 Nov 2012
    03 Oct 2013
    Link to this post
    Thanks mikem (and Telerik Support).
    I removed that line from my MVC > Controller > .CS file and it seems to have removed the error that I was getting.
  4. Atanas Valchev
    Atanas Valchev avatar
    414 posts
    Registered:
    04 Jan 2016
    04 Oct 2013
    Link to this post
    Hello Mikem,

    Thank you for sharing the solution with the community. 

    Regards,
    Atanas Valchev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 1 answered