MVC3 Razor视图无法在回发时呈现动态添加的控件

时间:2013-04-09 04:44:33

标签: asp.net-mvc-3 razor

我必须上传所选文件并在回发时将这些文件显示为链接。 在我看来,我使用

将每个上传的文件添加为链接
  @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);
    }

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

0 个答案:

没有答案