code_junkie

Using HttpModule instead of Global.asax

Nov 13th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <%@ Application Language="C#" %>
  2.  
  3. <script runat="server">
  4.  
  5. void Session_Start(object sender, EventArgs e)
  6. {
  7.  
  8.  
  9. }
  10.  
  11. </script>
  12.  
  13. public void Init(HttpApplication context)
  14. {
  15. context.BeginRequest += new EventHandler(Begin_Request);
  16. IHttpModule sessionModule = context.Modules["Session"];
  17. if(sessionModule != null &&
  18. sessionModule.GetType() == typeof(System.Web.SessionState.SessionStateModule))
  19. {
  20. (sessionModule as System.Web.SessionState.SessionStateModule).Start
  21. += new EventHandler(CustomHttpModule_Start);
  22. }
  23. }
  24.  
  25. <%@ Application Language="C#" CodeBehind="Global.asax.cs" Inherits="Global" %>
  26.  
  27. public class Global : System.Web.HttpApplication
  28. {
  29. public Global() { }
  30.  
  31. void Session_Start(object sender, EventArgs e)
  32. {
  33. // Code that runs when a new session is started
  34. }
  35. }
Add Comment
Please, Sign In to add comment