Asp.net MVC Spring 引导程序
我正在尝试创建一个引导程序,其中包含在 Spring.Net 容器中定义的任务(目前为 RegisterRoutes 和 RegisterControllerFactory)。 引导程序代码如下:
public static void Run()
{
IApplicationContext applicationContext = WebApplicationContext.GetRootContext();
IDictionary bootstrapperTasks = applicationContext.GetObjectsOfType(typeof(IBootstrapperTask));
foreach (IBootstrapperTask bootstrapperTask in bootstrapperTasks.Values)
bootstrapperTask.Execute();
}
问题是,如果我想在 Application_Start 方法中运行引导程序,WebApplicationContext 尚不可用 - 最早可用的阶段是 Init 方法。
但据我所知,Init 方法不是注册路由的好地方(请阅读: http://aspnet.codeplex.com/WorkItem/View.aspx?WorkItemId=3325)
是否有任何解决方法或者我应该手动创建一个引导程序(没有弹簧)?
谢谢
I am trying to create a bootstrapper with a tasks (for now RegisterRoutes and RegisterControllerFactory) defined in a Spring.Net container. The bootstrapper code is below:
public static void Run()
{
IApplicationContext applicationContext = WebApplicationContext.GetRootContext();
IDictionary bootstrapperTasks = applicationContext.GetObjectsOfType(typeof(IBootstrapperTask));
foreach (IBootstrapperTask bootstrapperTask in bootstrapperTasks.Values)
bootstrapperTask.Execute();
}
The problem is that if I want to run bootstrapper in a Application_Start method the WebApplicationContext is not available yet - the earliest stage where is available is the Init method.
But as I know the Init method is not a good place to register routes (read at: http://aspnet.codeplex.com/WorkItem/View.aspx?WorkItemId=3325)
Is there any workaround or should I create a bootstrapper manualy (without spring)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我没有将 Spring IOC 与 MVC (使用 Ninject)一起使用,这可能没有帮助,但您可以尝试
在 web.config 中注册引导程序对象
http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-instantiation< /a>
Since i haven't used spring IOC with MVC (using Ninject) this may not help but you could try
and register your bootstrapper objects in the web.config
http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-instantiation