The function to upload image:
[HttpPost]
public String UploadSingle(HttpPostedFileBase imageFile)
{
try
{
String fileSavePath = Server.MapPath("~/Content/Temp/" +
imageFile.FileName);
imageFile.SaveAs(fileSavePath);
List<String> uploadedFile = (List<String>)HttpContext.Session["UploadedFiles"];
if (uploadedFile == null)
{
uploadedFile = new List<string>();
}
uploadedFile.Add(fileSavePath);
HttpContext.Session["UploadedFiles"] = uploadedFile;
return "Success";
}
catch (Exception e)
{
return "Error";
}
}
This function work okay, the image is uploaded. But when i try to see the uploaded images.
public String UploadResult()
{
List<String> uploadedFile = (List<String>)HttpContext.Session["UploadedFiles"];
return uploadedFile.Count + "";
}
When i debug, the HttpContext.Session["UploadedFiles"] always return null. Please give me some help.