什么是WebActivator办? [英] What does WebActivator do?

查看:280
本文介绍了什么是WebActivator办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成这样code。使用的NuGet后增加实体框架code-首先用于SQL Server CE。他们这样做没有改变任何其他文件。文件 SQLCEEntityFramework.cs 创建并放置在 App_Start 文件夹中。

这是否意味着它会自动被执行的东西?同样的事情发生了,当我说Ninject为MVC 3号code被添加到 global.ascx 文件,所以我不知道,如果它的即插即用或I必须配置一些东西。

  [装配:WebActivator preApplicationStartMethod(typeof运算(StackTorrents.WebUI.App_Start.SQLCEEntityFramework),开始)


解决方案

<一个href=\"http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx\">http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx


  

这个新的属性可以让你有
  code运行在ASP.NET早方式
  管道作为一个应用程序启动。
  我的意思是这样的早期,甚​​至在
  的Application_Start。发生这种情况,
  也是前将APP_ code code
  文件夹(假设您有任何code在
  有)已经被编译。要使用此
  属性,创建一个类库和
  添加此属性作为一个组件
  级别属性。一个共同的地方加入
  这将是在AssemblyInfo.cs中
  属性文件夹中的类。


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")]

解决方案

According to:

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.

这篇关于什么是WebActivator办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆