2011-01-26 43 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應該工作了。

相關問題