Mega Code Archive

 
Categories / ASP.Net Tutorial / Development
 

HttpModule Tester

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"  Inherits="HttpModuleTester" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>HttpModuleTester</title> </head> <body>     <form id="form1" runat="server">     <div>          </div>     </form> </body> </html> File: Default.aspx.cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class HttpModuleTester : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         HttpContext myHttpContext = HttpContext.Current;         HttpApplication myHttpApplication = myHttpContext.ApplicationInstance;         HttpModuleCollection myHttpModuleCollection = myHttpApplication.Modules;         for (int index=0; index < myHttpModuleCollection.Count; index++)         {             IHttpModule module = myHttpModuleCollection.Get(index);             Response.Write("Module = " + module.ToString() + "<br>");         }         string httpModuleName = myHttpModuleCollection.GetKey(1);         Response.Write("The name of the HttpModule object at index 1" + " is " + "'" + httpModuleName + "'." + "<br><br>");         string[] allModules = myHttpModuleCollection.AllKeys;         Response.Write("<b>The HttpModule objects contained in the HttpModuleCollection are:</b><br>");         for (int i = 0; i < allModules.Length; i++)             Response.Write("Module " + i + "  : " + allModules[i] + "<br>");     } }