Hi, Guys.
I am using the Model-View-Presenter pattern in my project web and now I am with a doubt. How I do to treat session and cookie this scenario? How I do to write file using "Response.WriteFile" for example?
Hi, Guys.
I am using the Model-View-Presenter pattern in my project web and now I am with a doubt. How I do to treat session and cookie this scenario? How I do to write file using "Response.WriteFile" for example?
I think the most typical approach (and, in fact, the one used by ASP.Net MVC) is to wrap the HttpContext in an abstraction (like IContext or something) which exposes whatever subset of context functionality you need to get access to. If your using an IoC container, then you can pretty easily configure an IContext which has a default implementation that just calls HttpContext.Current under the covers. Things start to get a little trickier when you have to reference Session, and Request/Response objects, because you will typically need to wrap those as well (at least if you want to maintain testability in your presenter code). The trick is really to come up with some abstraction that works for you from an API perspective, and then just make that the way you deal with all of the nitty-gritty details.