0
我想在實現IHttpModule的類中設置會話變量。我收到「未設置爲對象實例的對象引用」。在實現IHttpModule錯誤的類中設置會話變量
這裏是我的代碼:
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += context_PreRequestHandlerExecute;
}
private void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication) sender;
HttpRequest request = app.Context.Request;
app.Session.Add("capath", request.QueryString["capath"].ToString());
}
請幫助。
上調用
.ToString()
在以下不爲空? request.QueryString [「capath」] –檢查這個http://stackoverflow.com/questions/276355/can-i-access-session-state-from-an-httpmodule – Damith
@MassimilianoPeluso omw,不能相信我錯過了所有這一切時間。謝謝。 –