Not getting timeout when expected or redirecting

Discussion in 'ASP.NET / ASP.NET Core' started by davehunt000, Jan 2, 2011.

  1. Hi,

    I have an ASP.net 4.0 application set up on DiscountASP.

    I have the config set up like this (2 minutes purposefully for testing)
    <authentication mode="Forms">
    <forms loginUrl="login.aspx" timeout="2"/>
    </authentication>
    <sessionState mode="SQLServer"
    allowCustomSqlDatabase="true"
    sqlConnectionString=x
    cookieless="false"
    timeout="2"/>

    Clearly I am missing something, as my application is not timing out in 2 minutes. When it does time-out, I'm getting an ASP.net error page, not getting kicked to login.aspx.

    Any help on this would be greatly appreciated.

    Thanks! Dave
     
  2. Here is the error I get

    If I just launch the app and let it sit on the login page for a while, when I try to login, this is the error I get. Unfortunately, Googling this error seems to imply that it is shown for a dozen or more different reasons. None of the usual responses (malformed <form> tags, page validation stuff) seem to apply here.

    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.

    Stack Trace:


    [ViewStateException: Invalid viewstate.
    Client IP: 66.235.54.76
    Port: 61701
    Referer: https://www.nhmclient.org/StaffMsgs.aspx
    Path: /StaffMsgs.aspx
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC; .NET4.0C; .NET4.0E)
    ViewState: /wEPDwUJNzE2MzM5Njk4D2QWAmYPZBYCAgMPZBYQAgEPDxYCHgRUZXh0BRpOZXcgSG9yaXpvbnMgQ2xpZW50IFN5c3RlbWRkAgUPDxYCHgdWaXNpYmxlaGRkAgcPDxYCHwAFEkxvZ2dlZCBpbiBhcyBEYXZlSGRkAgkPDxYCHwFoZGQCDQ8PFgIfAWhkZAIPDw8WAh8BZ2RkAhEPDxYCHwFnZGQCEw9kFgICDw88KwAJAQAPFgQeCERhdGFLZXlzFgAeC18hSXRlbUNvdW50AgJkFgRmD2QWBgIBDw8WAh4ISW1hZ2VVcmwFGi9oZWFkc2hvdHMvdGh1bWJfRGF2ZUguanBnZGQCAw9kFgwCAQ8PFgYeCUZvcmVDb2xvcgoxHwAFBURhdmVIHgRfIVNCAgRkZAIDDw8WAh4PQ29tbWFuZEFyZ3VtZW50BQEzZGQCBQ8PFgQfBwUBMx4LQ29tbWFuZE5hbWUFBkRlbGV0ZWRkAgcPDxYCHwAF5g1Ib3cgdG8gcmVwb3J0IGEgYnVnPGJyIC8+PGJyIC8+T3ZlciB0aGUgbmV4dCBmZXcgd2Vla3MsIGFzIHdlIGFyZSBzaGFraW5nIG91dCB0aGUgbmV3IHN5c3RlbSwgd2Ugd2lsbCBmaW5kIHNvbWUgYnVncy4gVGhpcyBpcywgdW5mb3J0dW5hdGVs...]

    [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.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
    System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +274
    System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
    System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
    System.Web.UI.HiddenFieldPageStatePersister.Load() +241
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    switch to use your own machine key in the web.config.
     
  4. machine key

    Thanks for the reply Bruce.

    Can you point me at a KB article or something that shows how to do that?

    thanks!
    Dave
     
  5. timeout issue

    There are sort of two issues here: the timeout not happening when I think it should, and then the result of it causing the error.

    Will the machine code fix both?

    Thanks
    Dave
     
  6. machinekey fix

    Just an FYI that the machinekey seems to have fixed this.

    <machineKey validationKey='8..0'
    decryptionKey='6..9'
    validation='SHA1'/>

    There are a number of sites around the web that will generate this for you. This one worked for me:
    http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx

    No entirely sure why, but the timeout issue also seemed to resolve itself.

    Dave
     
  7. Hi,
    I need some help and hope someone can help me :)
    I'm an end user of a software called "Certified Pro" and until recently have been able to load forms no problem. I just started recently getting this error:

    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.

    I can paste more details, but I'm wondering if this is something I have to fix on my end, or does the softwware company have to fix?
    Any input would be helpful
    Thanks
     
  8. dmitri

    dmitri DiscountASP.NET Staff

    Maria, this is a known issue and there are a number of ways to fix it. Please see this community post.
     

Share This Page