Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda