MVCTurbine 中 Application_Start 的替代品是什么?
显然,这个方法不再被调用......在那里我们有用于配置 AutoMapper 和设置模型绑定器的代码。
我知道有一种“新”方法来执行模型绑定程序,但是......在我实现该方法之前,我是否仍然可以使用“旧方法”?
具体来说,我的旧 Application_Start() 方法还剩下两行,我无法正常工作:
AutoMapperConfiguration.Configure();
ModelBinders.Binders[typeof (ModuleEditModel)] = new DerivedModelBinder();
我尝试简单地将它们弹出到构造函数中,就在调用之后: ServiceLocatorManager.SetLocatorProvider(() => new StructureMapServiceLocator());
这运行了,但是..似乎不知何故没有生效。在运行应用程序时,很明显 AutoMapper 不满意,没有它应该有的映射,等等。
Apparently, this method no longer gets called... In there we have code for configuring AutoMapper, and for setting model binders.
I know there is a "new" way to do model binders, but... shouldn't I still be able to do it "the old way" until I get that implemented?
Specifically, I have two lines left from my old Application_Start() method that I have been unable to get working:
AutoMapperConfiguration.Configure();
ModelBinders.Binders[typeof (ModuleEditModel)] = new DerivedModelBinder();
I've tried simply popping those into the constructor, right after the call to: ServiceLocatorManager.SetLocatorProvider(() => new StructureMapServiceLocator());
And that runs, but.. it seems somehow not to take effect. In running the application it is clear that AutoMapper isn't happy, doesn't have the mappings it is supposed to have, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 CodePlex 上的涡轮机讨论区上回答了这个问题。这是用于进行您要求的更改的来源:
希望这有帮助!
I answered this question out on the Turbine Discussion board on CodePlex. Here's the source for making the changes you ask for:
Hope this helps!