title: Invalid viewstate when using RewritePath
body: <p>I have this in my global.asax</p>
  
  <pre><code>void Application_BeginRequest(object sender, EventArgs e) 
  {
      string pathAndQuery = Request.Url.PathAndQuery.ToString().ToLower();
      if (pathAndQuery.Contains("prettyUrl"))
      {
          HttpContext.Current.RewritePath("Category.aspx?catg=uglyUrl");
      }
  }
  </code></pre>
  
  <p>it works fine, but I sometimes get this <strong>500 unable to validate data</strong>
  so i guess that is because the checksum is generated on behalf of the url. which does not match the viewstate.</p>
  
  <p>So how do you solve it so that you can use <code>RewritePath</code> but don't get the 500 errors?</p>
  
  <p><strong>Edit</strong> forgot to mention that i have a static machinekey validationkey in the web.config</p>
  
  <p><strong>Edit2</strong> found someone else has exactly the same problem: <a href="http://bytes.com/topic/asp-net/answers/298680-form-action-context-rewritepath#post1172026" rel="nofollow">http://bytes.com/topic/asp-net/answers/298680-form-action-context-rewritepath#post1172026</a></p>
  
  <p>the rewritepath causes an invalid viewstate when there is a postback</p>