asp.net-mvc - WebActivator 有什么作用?

标签 asp.net-mvc asp.net-mvc-3 ninject ef-code-first

此代码是在使用 NuGet 为 SQL Server CE 添加 Entity Framework 代码优先后生成的。他们没有对任何其他文件进行任何更改。文件 SQLCEEntityFramework.cs 已创建并放置在 App_Start 文件夹中。

这是否意味着它会自动执行或者什么?当我为 MVC 3 添加 Ninject 时,也发生了同样的事情。没有代码添加到 global.ascx 文件中,所以我不知道它是否即插即用,或者我必须配置一些东西。

[assembly: WebActivator.PreApplicationStartMethod(typeof(StackTorrents.WebUI.App_Start.SQLCEEntityFramework), "Start")]

最佳答案

根据:

http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx

This new attribute allows you to have code run way early in the ASP.NET pipeline as an application starts up. I mean way early, even before Application_Start. This happens to also be before code in your App_code folder (assuming you have any code in there) has been compiled. To use this attribute, create a class library and add this attribute as an assembly level attribute. A common place to add this would be in the AssemblyInfo.cs class within the Properties folder.

关于asp.net-mvc - WebActivator 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5812596/

相关文章:

asp.net-mvc - 在 Asp.net MVC 中抛出/返回 404 actionresult 或异常并让 IIS 处理它

c# - 如何将 'pass parameter' 添加到自定义 AuthorizeAttribute

asp.net-mvc - 基于路由数据值的 Ninject 注入(inject)

c# - 如何序列化工厂创建的对象

c# - Ninject - 创建自定义 NinjectWebServiceHost

c# - 将分割字符串交错作为列表 C#

asp.net-mvc - 最佳实践问题 - 直接使用 Linq to sql 类

javascript - 选择项目后选择 2(输入)值作为对象

asp.net - MVC : How to factor Repository Interfaces based on multi-level object model

javascript - 使用 MVC3 嵌套 JSON