title: Artificially populate HttpContext object in a Console application
body: <p>I am writing a wrapper library for log4net. This library should be able to capture Context information such as querystring, cookie, form fields etc. etc. </p>
  
  <p>I am invoking this wrapper class from Console application as opposed to TDD class. </p>
  
  <p>Is there a way to populate HttpContext object inside a Console application as follows?</p>
  
  <pre><code>HttpContext c = new HttpContext(null);
  c.Request.QueryString.Keys[1] = "city";
  c.Request.QueryString[1] = "Los Angeles";
  c.Request.QueryString.Keys[2] = "state";
  c.Request.QueryString[2] = "CA";
  </code></pre>
  
  <p>And then retrieve it as follows?</p>
  
  <pre><code>Console.WriteLine(context.Request.QueryString.Keys[1]);
  </code></pre>
  
  <p>I am getting the following exception when I attempt the above code.</p>
  
  <pre><code>Property or indexer 'System.Collections.Specialized.NameObjectCollectionBase.KeysCollection.this[int]' cannot be assigned to -- it is read only 
  </code></pre>