Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

92
Vistas
Download XML received from controller

I need to download an XML received from a controller, but I need the prompt to write a the name and the location where the file will be saved. First question: is optimal to send the xml like I did in this code or I should send it like a file in some way. Second question: receiving the xml or the xml file, how can open the prompt and finally save the xml like a file?

    [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) {
                  
                }
            });

        });
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda