Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you access HttpContext.Items from ApiController

  1. Is HttpContext.Items still considered a reasonable place to share things between different parts of a request? Particularly HttpHandler's outside of MVC, like WIF extensibility points.

  2. How do you access this dictionary from within MVC4's ApiController? Without using HttpContext.Current static methods (I still want it unit testable). The normal controller had HttpContextBase/Wrapper which abstracted it a bit for testing.

like image 369
Craig Celeste Avatar asked Apr 04 '12 19:04

Craig Celeste


1 Answers

Use Request.Properties inside the Web API Controller. When implementing an ActionFilterAttribute it's filterContext.Request.Properties

like image 143
Alexander Zeitler Avatar answered Oct 01 '22 08:10

Alexander Zeitler