Create your own machineKey

Discussion in 'ASP.NET 2.0' started by jzahoor, Nov 12, 2006.

  1. Aristotle,


    In order to fix the 20-min timeout issue, I went for your first option below and it seemed to work for a while. Now when I try to submit a form that was opened before application recycled, I get this...


    "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."


    Steps: form opened, app recycled, form submitted, error!


    I would like to attempt your second option that you mentioned below. I read through the article you posted but they ask for modification of machine.config.How do I implement that on DiscountASP.Net-hostedservers, knowing that I cannot modify your machine.config?


    Jimmy


    ------------------------------------------------------------------------------
    Posted 11/9/2006 12:30 PM (GMT -8)
    This is a problem with the forms authentication cookie. Data in the cookies are encrypted using a machineKey that gets generated randomly every time a web process gets recycled. Cookies that were created using the old machineKey will no longer be valid. We recycle web processes that have been idle (no hits whatsoever) for 20 minutes regardless of session timeout.


    To resolve this, you have a couple of options:


    1. Set the protection attribute in the forms element to "None".


    2. If you want to keep the protection enabled, you must create your own machineKey so that it's constant. See http://support.microsoft.com/kb/312906.


    --------------------------------------------------------------------------------
    Aristotle


    DiscountASP.NET
    www.DiscountASP.NET
     
  2. You can also set the enableViewStateMac property to False in the page element of the web.config.

    See http://msdn2.microsoft.com/en-us/library/950xf363.aspx


    But the best solution is to generate your own machineKey. It's used by ASP.NET in many things that you'll find that you'll be modifying so many parts of your application just to work around it.

    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET

    Post Edited (Aristotle [DASP]) : 11/14/2006 12:24:39 AM GMT
     

Share This Page