public static string GetParam(this IRequest httpReq, string name)
{
string value;
if ((value = httpReq.Headers[HttpHeaders.XParamOverridePrefix + name]) != null) return value;
if ((value = httpReq.QueryString[name]) != null) return value;
if ((value = httpReq.FormData[name]) != null) return value;
//IIS will assign null to params without a name: .../?some_value can be retrieved as req.Params[null]
//TryGetValue is not happy with null dictionary keys, so we should bail out here
if (IsNullOrEmpty(name)) return null;
Cookie cookie;
if (httpReq.Cookies.TryGetValue(name, out cookie)) return cookie.Value;
object oValue;
if (httpReq.Items.TryGetValue(name, out oValue)) return oValue.ToString();
return null;
}