Kod: Tümünü seç
using System;
using System.Web;
using System.Collections;
public class RHttpModule : IHttpModule
{
// In the Init function, register for HttpApplication
// events by adding your handlers.
public void Init(HttpApplication application)
{
application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
application.EndRequest += (new EventHandler(this.Application_EndRequest));
}
public string Code
{
get
{
if (HttpContext.Current.Session["CODE"] != null)
return (string)HttpContext.Current.Session["CODE"];
else
return null;
}
set
{
HttpContext.Current.Session["CODE"] = value;
}
}
// Your BeginRequest event handler.
private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
// context.Response.Write("<h3><font color=red>Hello: Beginning of Request</font></h3><hr>");
Code = "1";
}
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 24: set
Line 25: {
Line 26: HttpContext.Current.Session["CODE"] = value; Line 27: }
Line 28: }