asp.net mvc 操作采用 HttpPostedFileBase 参数:
public ActionResult Save(HttpPostedFileBase file)
{
//Q1: at the start of this action method, what's the status of this file?
//UploadCompleted or Uploading or something else?
//Q2: where is the file stored? memory or a temp file?
if (answer of Q1 is Uploading)
{
//Q3a: what happens if file.SaveAs is invoked?
//block the current thread until the file is uploaded?
}
else if (answer if Q1 is UploadCompleted)
{
//Q3b: which means the developer can do nothing before the file is uploaded?
//if the business logic limits the size of the file(e.g. <= 5MB), how can we
//prevent evil-intended uploading?
}
}
Q4 这里:我想记录这个请求的总时间,当用户开始上传文件时,定时器开始。当用户完成文件上传(或者我的Save
动作完成)时,定时器结束。我如何知道用户何时开始上传?