title: ASP.NET MVC - Post form to html bookmark?
body: <p>When using a form like this:</p>
  
  <pre><code>&lt;h2&gt;
  &lt;%:Model.EulaTitle %&gt;
  &lt;/h2&gt;
  &lt;p&gt;
  &lt;%=Model.EulaHtml %&gt;
  &lt;/p&gt;
  &lt;a name="errors"&gt;&lt;/a&gt;
  &lt;%:Html.ValidationSummary()%&gt;
  
  
  &lt;div style="text-align:center;"&gt;
  &lt;% using (Html.BeginForm())
     { %&gt;
  
  &lt;%:Html.HiddenFor(model =&gt; model.SourceUrl)%&gt;
  &lt;%:Html.HiddenFor(model =&gt; model.EulaId)%&gt;
  
  
  &lt;a name="accept"&gt;&lt;/a&gt;
  &lt;div style="text-align:center;"&gt;
  &lt;%:Html.CheckBoxFor(model =&gt; model.Accepted)%&gt;
  &lt;%:Html.LabelFor(model =&gt; model.Accepted)%&gt;
  &lt;/div&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;% } %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I need the page to scroll to <code>#errors</code> when it posts. The <code>Model.EulaHtml</code> contains some length EULA text and I'd prefer that the user not have to manually scroll down to see an error message if they post the page without accepting the agreement.</p>
  
  <p>If the controller detects <code>ModelState.IsValid</code> on Post, it redirects to another page. If not, I need to stay on this page, but scroll to the <code>#errors</code> bookmark anchor tag. </p>
  
  <p>I've thought about just adding '#errors' to the end of the url in the form action, but I receive errors along the line of <code>a potentially dangerous .... ('%')</code>. It's possible that I'm incorrectly encoding the hash mark. Anyone else had to deal with this? We're dealing with pretty restrictive requirements for browser compatibility (IE6+ and everything else under the sun) so I try to avoid using JavaScript whenever possible.</p>
  
  <p><strong>Update</strong></p>
  
  <p>The error I'm receiving is:</p>
  
  <pre><code>A potentially dangerous Request.Path value was detected from the client (%).
  </code></pre>
  
  <p>I modifed the <code>Html.BeginForm()</code> call to</p>
  
  <pre><code>&lt;% using (Html.BeginForm(new { @action="#errors" }))
     { %&gt;
  </code></pre>
  
  <p>And the resulting URL is:</p>
  
  <pre><code>http://..../TheControllerName/Eula/%2523errors/
  </code></pre>
  
  <p>I also noticed that a few queryString parameters that were being passed through disappear when I set the <code>action</code> attribute in this way.  (Not surprising, but no fix for that is immediately obvious to me)</p>