C# 建议ActionResult上载多个文件

C# 建议ActionResult上载多个文件,c#,asp.net-mvc,model-view-controller,actionresult,C#,Asp.net Mvc,Model View Controller,Actionresult,我有以下情况: 用户可以在其中上载多个文件的文档视图。一(文档)对多(文件)的关系。所有这些文件都在文档的IDDocument属性的“内部” 用户将加载.xml文件上载,每个文件上载将在我的控制器中触发该操作: [HttpPost] public ActionResult ProcessSubmitUpload(HttpPostedFileBase attachments, Guid? idDocument) { //Validations

我有以下情况:

用户可以在其中上载多个文件的文档视图。一(文档)对多(文件)的关系。所有这些文件都在文档的IDDocument属性的“内部”

用户将加载.xml文件上载,每个文件上载将在我的控制器中触发该操作:

    [HttpPost]
    public ActionResult ProcessSubmitUpload(HttpPostedFileBase attachments, Guid? idDocument)
    {
        //Validations
        var xmlDocument = XDocument.Load(attachments.InputStream);
        if (xmlDocument.Root.Name.LocalName == "cteProc")
        {
             if (DocumentCommonHelper.SendXmlViaWebService(xmlDocument))
             {                  
                      _documentRepository.UpdateDocumentStatus(StatusOption.DocumentApproved);
             }
             else
             {
                      _documentRepository.UpdateDocumentStatus(StatusOption.DocumentPending);
             }
         }
   }     
逻辑是:如果DocumentCommonHelper.SendXmlViaWebService(xmlDocument)中的所有文件都正确,则文档状态必须为“已批准”。但是,如果一个文件失败,文档状态必须为“挂起”

问题是该代码中的方法是错误的。因为它会在每次执行操作时更改文档的状态,从而忘记之前传递的其他HttpPostedFileBase


最好的方法是什么?

尝试在会话中存储HttpPostedFileBase,并在需要时将其检索回来

Session["HttpPostedFileBase"] = attachments;