gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 06:10:42 30 4
gpt4 key购买 nike

此代码是在使用 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com