Necesito descargar un XML recibido de un controlador, pero necesito el aviso para escribir el nombre y la ubicación donde se guardará el archivo. Primera pregunta: es óptimo enviar el xml como lo hice en este código o debería enviarlo como un archivo de alguna manera. Segunda pregunta: al recibir el xml o el archivo xml, ¿cómo puedo abrir el indicador y finalmente guardar el xml como un archivo?
[HttpPost] public ActionResult ExportFiles(string clientName, string currenthcsystem) { try { var systemActionsConfigurationData = service.GetHcSystemActionsConfigurationData(clientName,currenthcsystem); XmlSerializer xsSubmit = new XmlSerializer(typeof(HcSystemActionsConfigurationData)); var xml = ""; using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww)) { xsSubmit.Serialize(writer, systemActionsConfigurationData); xml = sww.ToString(); } } return Content(xml, "text/xml"); } catch (Exception) { throw; } } $('#exportButton').on("click", function () { var clientName = $(actionsButtons).data('clientname'); var currentHCSystem = $(actionsButtons).data('hcsystemname'); // Create FormData object var parameters = new FormData(); parameters.append("clientName", clientName); parameters.append("currentHCSystem", currentHCSystem); $.ajax({ url: $(actionsButtons).data('export'), type: 'POST', data: parameters, cache: false, processData: false, contentType: false, success: function (response) { //logic to open the prompt and finally download the xml }, error: function (err) { } }); });