【发布时间】:2011-03-17 01:46:20
【问题描述】:
我正在使用 MVC 3,我有一系列控制器取决于各种存储库,我的存储库中的 1 个依赖于 http 上下文会话。 为了使用 Windsor-Castle IoC,我为每个存储库创建了接口。
如何将当前会话对象向下传递到需要它的存储库?
我曾经能够做到这一点,“解决”会小心地将会话传递到需要它的存储库,不知何故我无法在最新版本(2011 年 2 月 2.5.3 日)中做到这一点:
Protected Overrides Function GetControllerInstance(ByVal requestContext As System.Web.Routing.RequestContext, _
ByVal controllerType As System.Type) As System.Web.Mvc.IController
Dim match As IController
' 1 or more components may need the session,
' adding it as a (possible) dependency
Dim deps As New Hashtable
deps.Add("session", HttpContext.Current.Session)
match = container.Resolve(controllerType, deps)
Return match
End Function
谢谢,文森特
【问题讨论】:
标签: castle-windsor ioc-container