我必须上传所选文件并在回发时将这些文件显示为链接。 在我看来,我使用
将每个上传的文件添加为链接 @if (Model.IncidentLogInfoDetails.AttachmentCollection.AttachmentItemCollection.Any())
{
foreach (EML.Container.Attachment attachmentItem in Model.IncidentLogInfoDetails.AttachmentCollection.AttachmentItemCollection)
{
@Html.ActionLink(attachmentItem.FileName, "testing")
}
}
这是我的控制器操作:
public ActionResult UploadingFiles(HttpPostedFileBase imageFile)
{
// Converting to Attachment object
Attachment fileAttachment = new Attachment();
fileAttachment.FileName = "imageFile.FileName";
fileAttachment.ContentType = imageFile.ContentType;
fileAttachment.SizeInBytes = imageFile.ContentLength;
using (MemoryStream ms = new MemoryStream())
{
imageFile.InputStream.CopyTo(ms);
fileAttachment.BinaryData = ms.GetBuffer();
}
IncidentDetails incidentDetails = new IncidentDetails();
incidentDetails.IncidentLogInfoDetails = new IncidentLogInfo();
incidentDetails.IncidentLogInfoDetails.AttachmentCollection.AttachmentItemCollection = new List<Attachment>();
incidentDetails.IncidentLogInfoDetails.AttachmentCollection.AttachmentItemCollection.Add(fileAttachment);
return View("FileUploadingTest", incidentDetails);
}
我的问题是,即使循环正在执行并且创建了动作链接(在调试时),它们也不会在回发后显示。
我错过了什么?