1

我必须上传选定的文件并将这些文件显示为回发的链接。在我看来,我将每个上传的文件添加为使用链接

  @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);
    }

我的问题是,即使正在执行循环并创建了操作链接(在调试时),它们在回发后也不会显示。
我错过了什么?

4

0 回答 0