WebActivator 有什么作用?
此代码是在使用 NuGet 为 SQL Server CE 添加实体框架代码优先后生成的。他们没有对任何其他文件进行任何更改。文件 SQLCEEntityFramework.cs
已创建并放置在 App_Start
文件夹中。
这是否意味着它会自动执行或其他什么?当我为 MVC 3 添加 Ninject 时,也发生了同样的事情。没有代码添加到 global.ascx 文件中,所以我不知道它是否即插即用,或者我必须配置一些东西。
[assembly: WebActivator.PreApplicationStartMethod(typeof(StackTorrents.WebUI.App_Start.SQLCEEntityFramework), "Start")]
This code was generated for me after added entity framework code-first for SQL Server CE using NuGet. They did no changes to any other file. The file SQLCEEntityFramework.cs
was created and placed in App_Start
folder.
Does this mean it automatically gets executed or something? The same thing happened when I added Ninject for MVC 3. No code was added to the global.ascx
file so I have no idea if its plug and play or I have to configure something.
[assembly: WebActivator.PreApplicationStartMethod(typeof(StackTorrents.WebUI.App_Start.SQLCEEntityFramework), "Start")]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据:
http://haacked.com /archive/2010/05/16/三隐藏扩展性-gems-in-asp-net-4.aspx
According to:
http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx
为了澄清,它为您提供了一种挂钩多个应用程序启动和应用程序关闭事件的方法,而无需更改任何现有代码文件(以前您必须编辑 Globals.asax.cs)。
这在制作包时是一件大事,因为这些事件对于引导 Http 模块非常有用,并且将代码写入现有文件确实很困难。
To clarify, it gives you a way of hooking into several application start and application shutdown events WITHOUT having to change any existing code files (previously you had to edit Globals.asax.cs).
This is mostly a big deal when making packages as these events are really useful for bootstrapping Http modules and it is really difficult to write code into existing files.