So to do that there is 2 ways :
1- Using IHttpModule.
2- Using Global.asax Event.
===============
1- Create New Class Library Project named for E.g "KNGenericHandlers":
================
A- First Using IHttpModule :
A-1- Add Class named -> KNModule.cs
namespace KNGenericHandlers
{
public class KNModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.BeginRequest += context_BeginRequest;
}
void context_BeginRequest(object sender, EventArgs e)
{
//Your Code
}
public void Dispose()
{
}
}
}
A-2- In Sharepoint Web.Config inside "<system.webServer>" -> "<modules runAllManagedModulesForAllRequests="true">"
Add : <add name="KNModule" type="KNGenericHandlers.KNModule" />
================
B- Other Way Using IHttpModule :
B-1- Add Class Global.cs:
---
namespace KNGenericHandlers
{
public partial class Global : Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication
{
//KNGenericHandlers.Global
public Global() { }
protected void Application_EndRequest(Object sender, EventArgs e)
{
//ADD YOUR CODE
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
//InitializeKentico Ini = new InitializeKentico();
}
}
}
---
B-2-In your Sharepoint "global.asax" Edit the file to point to your class Library like :
---------
<%@ Assembly Name="KNGenericHandlers"%>
<%@ Import Namespace="KNGenericHandlers" %>
<%@ Application Language="C#" Inherits="KNGenericHandlers.Global" %>
---------
================
No comments:
Post a Comment