在FileUpload

时间:2017-04-04 03:34:09

标签: c# session

当我将文件上传到我的网站时,我丢失了会话,用户应该再次登录? 这是我的代码

if (FileUploadControl.HasFile) {
    string filename = Path.GetFileName(FileUploadControl.FileName);
    string newFileName = Path.Combine(Path.GetDirectoryName(filename),
        string.Concat(words[0], DateTime.Now.ToString("_yyyy_MM_dd_HH_mm_ss"),
            Path.GetExtension(filename)));

    Session["login"] = us.Email;
    Session["Id"] = us.Id;

    string location = usDetail.FolderLink.Trim();
    FileUploadControl.SaveAs(Server.MapPath(location) + newFileName);
    lblResult.Text = "the file" + newFileName + " has uploaded";

    var dateAndTime = DateTime.UtcNow;
    var date = dateAndTime.Date;

    var fp = new FileUpoads(usDetail.Id, DropDownList2.SelectedValue.ToString().Trim(),
        location + newFileName, date);

    string f = ConnectionClass.FileUplud(fp);
    lblResult.Text = f;
}

0 个答案:

没有答案