在 Application_Start 和 Application_Endrequest 中挂接和运行一些代码而不必每次都将代码放在 MvcApplication 类中的首选方法是什么?
也许有一个事件、一个属性或我可以在 asp.net 4 中连接的东西?
最佳答案
有很多 events on the HttpApplication class .但是,您仍然需要一些东西来引导事件连接。
你可以看看PreApplicationStartAttribute .它允许您在应用程序编译之前连接代码以运行(尽管 Application 实例不会那么早可用)。
David Ebbo 还创建了一个名为 WebActivator 的类似系统.
关于asp.net-mvc-3 - 在 Application_Start 中设置和运行代码的首选方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4199634/