Hi,
HttpContext context = ((HttpApplication)sender).Context;
In the above example, why do we cast sender to a HTTPApplication and not HTTPContext?
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:
(sender).Context;
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.
Secondly:
string url = context.Request["url"];
int cacheDuration = Convert.ToInt32(context.Request["cache"] ?? "0");
string contentType = context.Request["type"];
EDIT: I realised that you can write:
collection["key"] = "value";
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"?
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?
Thanks