Explanation on how this code using web namespace
<pre><code>HttpContext context = ((HttpApplication)sender).Context;
</code></pre>

<p>In the above example, why do we cast sender to a HTTPApplication and not HTTPContext? </p>

<p>Also, what is the purpose of the brackets? I know they are for casting, but if you get rid of HTTPApplication and the surrounding brackets, that leaves:</p>

<pre><code>(sender).Context;
</code></pre>

<p>Why not sender.Context? Or generically, why the use of brackets anyway? I vaguely remember it is a way of casting but can't remember specifics.</p>

<p>Secondly:</p>

<pre><code> string url = context.Request["url"];
 int cacheDuration = Convert.ToInt32(context.Request["cache"] ?? "0");
 string contentType = context.Request["type"];
</code></pre>

<p>EDIT: I realised that you can write:</p>

<pre><code>collection["key"] = "value";
</code></pre>

<p>This is for a key-based collection and you store value where there is a key called "key". So am I right in thinking you get the url where the key is "url"?</p>

<p>I know this is using HTTPContext, but in the indexer, what is "url" meant to mean? It is just a string saying url, not even a real url. Likewise for "cache" and "type". If one writes "type", as in the last line of code, does that get back the type (HTTP/HTTPS) used?</p>

<p>Thanks</p>
