ASP.NET MVC Access Application Property From Model
my global.asax looks like this:
Imports Castle.Windsor
Imports Castle.Windsor.Configuration.Interpreters
Public Class MvcApplication
Inherits System.Web.HttpApplication
Implements IContainerAccessor
Private Shared IoC As IWindsorContainer
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
' MapRoute takes the following parameters, in order:
' (1) Route name
' (2) URL with parameters
' (3) Parameter defaults
routes.MapRoute( _
"Default", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = ""} _
)
End Sub
Sub Application_Start()
RegisterRoutes(RouteTable.Routes)
IoC = New WindsorContainer(New XmlInterpreter)
End Sub
Public ReadOnly Property Container() As Castle.Windsor.IWindsorContainer Implements Castle.Windsor.IContainerAccessor.Container
Get
Return IoC
End Get
End Property
End Class
How can I access the Container property from any model class? there is a class that I inherit that gives me the "Application" property like in the view so I can do this
IoC = Application.Item ("Container") ...
0
source to share