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

178
Views
Getting the file return value from controller to ajax/javascript

I am trying to get this returned value from my controller.

Controller:

 public ActionResult TestView(string StudentID, string SQNC)
      {
         string query = "exec sp_someStoredProcedure '" + StudentID + "','" + SQNC + "' ";
         string dataStr = GlobalFunction.DataTableToJSON(GlobalFunction.TableFromMSSQL(CampusConnect, query));
         dynamic data = JsonConvert.DeserializeObject(dataStr);
         byte[] file = data[0].ImgVarbinary;

         return File(file, System.Net.Mime.MediaTypeNames.Application.Octet, (string)data[0].FileName);
      }

My Script (on button click)

const test = (studid, sqncno) => {
      $.ajax({
            type: "POST",
            dataType: "json",
            url: "/ViewUpload/TestView",
            data: {
               'StudentID': studid,
               'SQNC': sqncno,
            },
         success: function (result) {
            console.log(result);
         }
      });
   }

When I running the program, it did not get the return value in success function.

My goal is to get this file value and convert it into base64 string in javascript so I can make it viewable to front-end.

As you can see on the controller, I'm getting the Varbinary string of the file from the database. I tried converting it directly to SQL into base64 string but for some reason It doesn't work (my previous question I made) so I'm trying this approach of getting the file and converting it to base64 into javascript instead.

Thanks for answer.

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!