Passing (Asp.Net) Session variable (uploaded by uploadify) from webmethod to same page?
When i try to get uploaded filename from generic handler (upload.ashx) using session its ok, no problem. I can also use webmethod on samepage and uploadify works great, but Session["fileName"] is getting null. Is there anything wrong on my code? Do i only need to use generic handler to get filename?
[WebMethod(EnableSession = true)]
public void LoadPicture(HttpContext context)
{
try
{
HttpPostedFile file = context.Request.Files["Filedata"];
context.Session["fileName"] = file.FileName;
....................Some resize and save image codes.........
context.Response.Write("1");
}
catch (Exception ex)
{
context.Response.Write("0");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
using (_modelService = new ModelService())
{
ModelEntity _models = new ModelEntity();
......some codes....
_models.modelphoto = Session["fileName"].ToString();
_modelService.ModelAdd(_models);
}
}
Uploadify uses Flash. Flash doesn't send cookies. In ASP.NET sessions are tracked by cookies. So, no session with uploadify, sorry.
精彩评论