ASP.NET MVC: Is it good to access HttpContext in a controller?
- by Zach
I've been working with ASP.NET(WebForm) for a while, but new to ASP.NET MVC. From many articles I've read, in most cases the reason that the controllers are hard to test is because they are accessing the runtime components: HttpContext (including Request, Response ...). Accessing HttpContext in a controller seems bad.
However, I must access these components somewhere, reading input from Request, sending results back via Response, and using Session to hold a few state variables.
So where is the best place to access these runtime components if we don't access them in a controller?
Best regards,
Zach@Shine