我之前已经将一个文件上传到我的数据库中,现在我想从我的数据库中下载该文件。
谁能告诉我怎么做?我是 C# 和 ASP.NET MVC 的新手。
控制器 :
public ActionResult Details(string id = null)
{
Assignment assignment = db.Assignments.Find(id);
if (assignment == null)
{
return HttpNotFound();
}
return View(assignment);
}
模型:
public string AssignmentID { get; set; }
public Nullable<System.DateTime> SubmissionDate { get; set; }
public string Status { get; set; }
[Range(0,100, ErrorMessage="Only Value between 0-100 is accepted.")]
public Nullable<decimal> Mark { get; set; }
public string Comments { get; set; }
public byte[] FileLocation { get; set; }
看法:
<div class="display-label">
<%: Html.DisplayNameFor(model => model.FileLocation) %>
</div>
<div class="display-field">
<%: Html.DisplayFor(model => model.FileLocation) %>
</div>