public static HttpContextBase GetHttpContext(this HttpRequestMessage request) { if (request == null) { throw new ArgumentNullException("request"); } HttpContextBase context; if (request.IsBatchRequest()) { if (!request.Properties.TryGetValue(HttpBatchContextKey, out context)) { if (request.Properties.TryGetValue(HttpContextBaseKey, out context)) { context = new HttpBatchContextWrapper(context, request); request.Properties[HttpBatchContextKey] = context; } else { context = null; } } } else if (!request.Properties.TryGetValue(HttpContextBaseKey, out context)) { context = null; } return(context); }
public static HttpContextBase GetHttpContext(this HttpRequestMessage request) { if (request == null) { throw new ArgumentNullException("request"); } HttpContextBase context; if (request.IsBatchRequest()) { if (!request.Properties.TryGetValue(HttpBatchContextKey, out context)) { if (request.Properties.TryGetValue(HttpContextBaseKey, out context)) { context = new HttpBatchContextWrapper(context, request); request.Properties[HttpBatchContextKey] = context; } else { context = null; } } } else if (!request.Properties.TryGetValue(HttpContextBaseKey, out context)) { context = null; } return context; }