Axi*_*ili 9 umbraco global-asax
我的Global.asax中有以下内容(Umbraco 4.7)
现在我已升级到Umbraco 6.0.3,global.asax继承自 Umbraco.Web.UmbracoApplication
我在哪里放置我的事件处理程序(以及等效的方法名称)?
Axi*_*ili 18
这是我到目前为止所发现的.
您可以创建自己的类
public class Global : Umbraco.Web.UmbracoApplication
{
public void Init(HttpApplication application)
{
application.PreRequestHandlerExecute += new EventHandler(application_PreRequestHandlerExecute);
application.EndRequest += (new EventHandler(this.Application_EndRequest));
//application.Error += new EventHandler(Application_Error); // Overriding this below
}
protected override void OnApplicationStarted(object sender, EventArgs e)
{
base.OnApplicationStarted(sender, e);
// Your code here
}
private void application_PreRequestHandlerExecute(object sender, EventArgs e)
{
try
{
if (Session != null && Session.IsNewSession)
{
// Your code here
}
}
catch(Exception ex) { }
}
private void Application_BeginRequest(object sender, EventArgs e)
{
try { UmbracoFunctions.RenderCustomTree(typeof(CustomTree_Manage), "manage"); }
catch { }
}
private void Application_EndRequest(object sender, EventArgs e)
{
// Your code here
}
protected new void Application_Error(object sender, EventArgs e)
{
// Your error handling here
}
}
Run Code Online (Sandbox Code Playgroud)
并让Global.asax从您的类继承
<%@ Application Codebehind="Global.asax.cs" Inherits="Global" Language="C#" %>
Run Code Online (Sandbox Code Playgroud)
替代方法:继承ApplicationEventHandler - 但它对我不起作用
| 归档时间: |
|
| 查看次数: |
6328 次 |
| 最近记录: |