2011-01-26 97 views

回答

15

我猜想Session是这里的罪魁祸首;参考here,您可能想尝试将: IRequiresSessionState添加到您的处理程序中(ashx的代码隐藏)。所以,你应该有类似:

public class Handler1 : IHttpHandler, System.Web.SessionState.IRequiresSessionState 
{ 

    public void ProcessRequest(HttpContext context) 
    { 
     context.Response.ContentType = "text/plain"; 
     context.Response.Write("Hello World"); 
     context.Session["loggedIn"] = true; 
    } 

    public bool IsReusable 
    { 
     get 
     { 
      return false; 
     } 
    } 
} 

还要注意,很容易去跟context传入,但HttpContext.Current应该工作了。

相关问题