重典的博客 发表于 2012-10-26 00:01:09

使用PreApplicationStartMethodAttribute添加Application_Start事件

先预备一个类,用于Start时调用
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">   public static class MyPreApplicationStart       {         public static void RegisterGlobalFilters(GlobalFilterCollection filters)         {               if (filters != null)                   filters.Add(new HandleErrorAttribute());         }              public static void Start()         {               RegisterGlobalFilters(GlobalFilters.Filters);         }       }
页: [1]
查看完整版本: 使用PreApplicationStartMethodAttribute添加Application_Start事件