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

182
Visualizações
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
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