次の方法で共有


How to access HTTPContext from within your Web API action

Within a Web API action, you can easily access the HttpContext via the HttpContext.Current thread static. Alternatively, you can also retrieve the context from one of the properties in the Request message.

Code Snippet

  1. HttpContext context;
  2. Request.Properties.TryGetValue<HttpContext>("MS_HttpContext", out context);

Hope this helps.