MVP会话响应请求 [英] mvp session response request

查看:150
本文介绍了MVP会话响应请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的模型 - 视图 - presenter模式在我的项目的网络,现在我有一个疑问。我该怎么办治疗会话和饼干这种情况?我如何使用Response.WriteFile,例如写文件?

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?

推荐答案

我觉得最典型的做法(而且,事实上,由ASP.Net MVC使用的)是包裹在HttpContext的抽象(如IContext或东西),它暴露了你需要获得访问任何上下文的功能子集。如果您使用的是IoC容器,那么你可以pretty轻松配置具有只是调用HttpContext.Current在幕后的默认实现的IContext。事情开始变得有点棘手,当你必须引用会议,并请求/响应对象,因为你通常需要包装的,以及(至少如果你想在你的presenter code,以保持可测性) 。诀窍是真的要来了一些抽象,从API的角度为你的作品,然后只是使你的方式处理所有的细枝末节。

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.

这篇关于MVP会话响应请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆