VUE axios怎么向.NET CORE请求的验证码啊

那位大哥知道怎么把VUE axios向.NET CORE请求的图片显示到Image标签中啊,一直乱码,卡了一周了,网上的方法全都试了一遍,逼得我只有存到本地再取出实现显示图片了,啊啊啊

 

.NET CORE

  [HttpGet]
        public IActionResult GetVarifyCode()
        {
            string varifyCode = string.Empty;
            string pathOrigin = new DirectoryInfo(_webHostEnvironment.ContentRootPath).Parent.Parent.Parent.FullName + @"\whww-blog-vue\public\varifyImage";
            string time = DateTime.Now.ToString("yyyyMMdd");
            string path = pathOrigin + @"\" + time;
            if (!Directory.Exists(path))
            {
                FileHelper.deleteFile(pathOrigin);
                Directory.CreateDirectory(path);
            }
            MemoryStream ms = VarifyCode.Create(out varifyCode, 4);
            string file = DateTime.Now.ToString("yyyyMMddhhmmss") + ".jpeg";
            path = path +@"\"+ file;
            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(ms.ToArray());
                bw.Close();
            }
            byte[] vs = Encoding.Default.GetBytes(varifyCode);
            HttpContext.Session.Set("varifyCode", vs);
              return File(ms.ToArray(), "image/png");
           // return File(ms.ToArray(), "application/octet-stream;charset=utf-8");
            // return Ok(new AjaxResponse() { Result = @"/varifyImage/"+time+"/"+ file, Success = true });
        }

vue

 GetVarifyCode() {
      this.http
        .GetVarifyCode('Public/GetVarifyCode')
        .then((res) => {
          this.src = res;
          console.log(res);
          return (
            'data:image/png;base64,' +
            btoa(
              new Uint8Array(res).reduce(
                (data, byte) => data + String.fromCharCode(byte),
                ''
              )
            )
          );
        })
        .then((data) => {
          //this.src = data;
          console.log(data);
        });

 

你返回的是流媒体数据base64,不是一个字符串url吧?

我觉得吧,箭头函数的this指向是变化的 ,你得用that 倒一下?

箭头函数的this是没有问题的,返回的是字节数组,不是url,但是接受的速时候不能显示,用swagger和postman就能显示