我在 app_code 文件夹中有一个自定义的 httphandler,我想在这个类中使用会话但是有一个异常消息,这里是代码
public void ProcessRequest(HttpContext context)
{
HttpRequest request = context.Request;
HttpResponse response = context.Response;
HttpContext.Current.Session["UserID"] = "ABC";
response.Write(HttpContext.Current.Session["UserID"].ToString());
}
错误信息:
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.
有谁知道是什么问题>