使用PreApplicationStartMethodAttribute添加Application_Start事件

简介: 先预备一个类,用于Start时调用 public static class MyPreApplicationStart { public static void RegisterGlobalFilters(GlobalFilt...

先预备一个类,用于Start时调用

public static class MyPreApplicationStart
   {
       public static void RegisterGlobalFilters(GlobalFilterCollection filters)
       {
           if (filters != null)
               filters.Add(new HandleErrorAttribute());
       }
 
       public static void Start()
       {
           RegisterGlobalFilters(GlobalFilters.Filters);
       }
   }
这之后通过PreApplicationStartMethodAttribute注册到assembly即可,需要注意的是自定义类必须public ,其中用记Start的方法必须public static
[assembly: PreApplicationStartMethod(typeof(MyPreApplicationStart), "Start")]

Reference:

http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=ZH-CN&k=k(SYSTEM.WEB.PREAPPLICATIONSTARTMETHODATTRIBUTE);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&rd=true

http://msdn.microsoft.com/zh-cn/library/gg401977(v=vs.98)

目录
相关文章
|
数据库
FastAPI(55)- Events: startup - shutdown 启动/关闭事件
FastAPI(55)- Events: startup - shutdown 启动/关闭事件
291 0
FastAPI(55)- Events: startup - shutdown 启动/关闭事件
|
NoSQL API 语音技术
Freeswitch如何接收 RECORD_STOP 和 RECORD_START事件
Freeswitch如何接收 RECORD_STOP 和 RECORD_START事件
|
5月前
Error starting ApplicationContext. To display the auto-configuration report re-run your application
Error starting ApplicationContext. To display the auto-configuration report re-run your application
|
9月前
|
JavaScript
Notification.description(ant-design) 和 $notify.message(element-ui) 通知内容自定义
Notification.description(ant-design) 和 $notify.message(element-ui) 通知内容自定义
239 0
|
程序员
Callback、Listener、Worker、Manager的命名说明
Callback、Listener、Worker、Manager的命名说明
62 0
|
Dubbo Java 应用服务中间件
实现 Application1 调用 Service1 | 学习笔记
快速学习实现 Application1 调用 Service1。
49 0
|
应用服务中间件 数据格式 XML
解决tomcat stop报Illegal access: this web application instance has been stopped异常方法
解决tomcat stop报Illegal access: this web application instance has been stopped异常方法 运行shutdown.bat/shutdown.
5284 0
|
Web App开发
使用application log 分析navigation target解析错误
使用application log 分析navigation target解析错误
使用application log 分析navigation target解析错误
使用application log分析Fiori navigation target解析错误
当点击tile时遇到error message “Cannot open application”, F12里能找出详细的error log number:
使用application log分析Fiori navigation target解析错误
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta
I woud like to change this extension field in third party system outside C4C, using web service or OData service. I have created a new action in BO CustomerQuote:
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta