ASP.NET 4 中的 PreApplicationStartMethod 是个好东西吗?
免责声明: 这是我第一次提出一个可能被归类为主观的问题。由于英语不是我的母语,因此很难正确表达这一点。因此,请随意编辑问题以使其更清楚,或者向我指出提出此问题的其他方式。
简介: David Ebbo(ASP.NET 团队的架构师)刚刚发布于 使用 在运行时无需配置即可注册 HTTP 模块看似未记录的 PreApplicationStartMethod 程序集级别属性
我对此有复杂的感觉。
一方面,能够在应用程序启动阶段尽早完成工作是件好事。
另一方面:够了吗?我们是否需要一个PrePreApplicationStartMethod来允许摆弄PreApplicationStartMethod行为?扩展到非汇编用途怎么样(例如,NuGet 已经 可以解决 PreApplicationStartMethod 的每个程序集单一使用限制)?
问题:除了将其用于无配置启动之外,您对 PreApplicationStartMethod 属性有何看法?
Disclaimer:
This is the first time I am asking a question that might be classified as subjective. As English is not my first language, it is hard to phrase this right. So please feel free to edit the question in order to make it clearer, or to point me at other ways for asking this.
Intro:
David Ebbo (architect on the ASP.NET team) just posted on Register your HTTP modules at runtime without config using the seemingly undocumented PreApplicationStartMethod assembly level attribute
I have mixed feelings about it.
On the one hand it is good to be able to do things as early in the application startup phase as possible.
On the other hand: Does it suffice? Do we need a PrePreApplicationStartMethod allowing to fiddle with the PreApplicationStartMethod behaviour? What about expansion to non-assembly use (for instance, NuGet already works around the single-use-per-assembly restriction of PreApplicationStartMethod)?
Question: Besides using it for config-less startup, what do you think of the PreApplicationStartMethod attribute?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这样做的一个很好的用途是,它允许正在编写第 3 方程序集的人或正在开发将在许多项目中使用的程序集的团队能够使用此属性来初始化 w 的东西/o 要求最终用户/开发人员在应用程序启动事件中的 global.asax 中创建任何内容。
人们喜欢/需要在 global.asax 中配置许多应用程序特定的内容,但是如果您正在创建 DLL,则不再需要让用户在 global.asax 中配置您的类,您可以将所有您的逻辑位于您自己的 init/bootstrap 函数中,并在应用程序启动时依赖 asp.net 调用您的 init 逻辑。
I think one of the good usages for this is that it allows someone who is writing a 3rd party assembly, or a team that is working on an assembly that will be used in many projects, to be able to use this attribute to initialize stuff w/o requiring the end user/developer to create anything in the global.asax in the application startup events.
There are lots of app specific stuff that people like to/need to configure in global.asax, but if you are creating a DLL, you no longer have to make the user configure your classes in the global.asax, you can just put all your logic in your own init/bootstrap function and rely on asp.net to call your init logic when the app starts.