session set in ashx and get that session on aspx
The following code is working on IE but not on Firefox. The following code is setting session on *.ashx file.
public class Upload : IHttpHandler, IRequiresSessionState
{
public string PATH = System.Web.HttpContext.Current.Request.MapPath("..") + @"\UploadFiles\";
public string prefix = "ANNUAL_";
public void ProcessRequest(HttpContext context)
{
HttpPostedFile file = context.Request.Files["Filedata"];
file.SaveAs(PATH + prefix + file.FileName);
HttpContext.Current.Session["filename"] = file.FileName;
context.Response.Write("1");
}
}
Getting session in *.aspx file is as follows. Even though I can set value into the sessions in *ashx file, the session value is null when session arrives in the *.aspx file. How can I solve my problem? Could you please give any solution about my problem?
using System.Web.SessionState;
public partial class frmImport : System.Web.UI.Page, IReadOnlySessionState
{
protected void btnSave_Click(object sender,开发者_运维知识库 EventArgs e)
{
string temp = HttpContext.Current.Session["filename"].ToString();
}
}
Put the following code in Web.Config
<configuration>
<system.web>
<sessionState mode="InProc" cookieless="true" />
The problem has gone !
Here is the TRUE solution to fix this: How to access session in aspx that was modified in ashx?
It's because flash does not send the sessionid to the handler.
精彩评论