у меня есть aspx страница и обычай httphandler в той же самой области. На aspx странице (test.aspx), я использую
<%@ Page Language="C#" %>
<%
HttpContext.Current.Session["UserID"] = "ABC";
%>
создать переменную сеанса, но когда я хочу назвать переменную в httphandler
public class JpgHttpHandler : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
response.Write(HttpContext.Current.Session["UserID"].ToString());
}
}
есть сообщение об ошибке когда я пуговица httphandler:
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.
как я могу назвать сессию от httphandler?
спасибо
Update
измененный код на
if (context.Session["UserID"] != null)
response.Write(context.Session["UserID"].ToString());
странно, когда я использую IP, чтобы получить доступ к веб-странице, это работает. Но я использую доступ доменного имени страница, он показывает бланк