我使用的是MVC 3,根据不同的存储库我有一系列控制器,我的存储库中有一个依赖于http上下文会话。 为了使用Windsor-Castle IoC,我为每个存储库创建了接口。Windsor Castle IoC - Http Session
如何将当前会话对象传递给需要它的存储库?
我曾经是能够做到这一点和“解决”会照顾会话传递给需要它的存储库中,不知何故,我不能在最新版本中做到这一点(2.5.3 2011年2月):
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
谢谢,文森特