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

160
Visualizações
How send string parameter using Post Method from the view to the controller ASP.NET

I'm having a element that called scanned-result that is having a list of barcodes, after I get all the codes I'm using the querySelectorAll from the elements I'm saving it in a String Array and then I send this list into the controller. What can I do to send this array parameter urlParameter as a Post Method instead of use window.location.href to the controller?

When I start scanning the barcodes will save in results.innerHTML


function startScanning(facingMode) {
        console.log(facingMode)
        var results = document.getElementById('scanned-result');
       function onScanSuccess(qrCodeMessage) {
            if (lastMessage !== qrCodeMessage) {
                lastMessage = qrCodeMessage;
                ++codesFound;

               results.innerHTML += `<div> ${qrCodeMessage}</div>`;
               

            }
        }
      

When stop scanning I'm going to get the array looking by the element scanned-result sending the array to the controller, Here is when I'm stuck I'm not sure what I need to change to make it to send the parameter as a Post Method

 function stopScanning() {

          
        var QRCodeval = document.querySelectorAll("#scanned-result>div");
        var arr = [];
        QRCodeval.forEach((el) => arr.push(el.innerHTML));

        let urlParams = arr.map((val) => {
            return `arr=${encodeURIComponent(val)}`
        }).join('&');

     window.location.href = "@Url.Action("ReceivedFromBarCode", "PurchaseOrder")?arr" + urlParams;
}

In the View is going to appear the values on id="scanned-result"


<div class="modal-footer">
 <div id="scanned-result""> 
 </div>
 

           

Controller


[HttpPost]
 public async Task<ActionResult> ReceivedFromBarCode(string[] arr)

        {
            try
            {
                }
                return RedirectToAction($"Details");
            }
            catch (VTHIS.CommunicationException cex)
            {
                throw cex;
            }

        }
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