Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!