title: How to determine the encoding of request query string
body: <p>Suppose I have a .NET <code>HttpModule</code> that analyzes incoming requests to check for possible attacks like <code>Sql Injection</code>. 
  Now suppose that a user of my application enters the following in a form field and submits it:</p>
  
  <pre><code>&amp;#039&amp;#032&amp;#079&amp;#082&amp;#032&amp;#049&amp;#061&amp;#049
  </code></pre>
  
  <p>That is Unicode for <code>' OR 1=1</code>. So in the request I get something like:</p>
  
  <pre><code>http://example.com/?q=%26%23039%26%23032%26%23079%26%23082%26%23032%26%23049%26%23061%26%23049
  </code></pre>
  
  <p>Which in my <code>HttpModule</code> looks fine (no Sql Injection), but the server will correctly decode it to <code>q=' OR 1=1</code> and my filter will fail.</p>
  
  <p>So, my question is: <code>Is there any way to know at that point what is the encoding used by the request query string, so I can decode it and detect the attack?</code></p>
  
  <p>I guess the browser has to tell the server which encoding the request is in, so it can be correctly decoded. Or am I wrong?</p>