base64转图片后刷新网页

Refresh Web Page after Converting base64 to image

我有一个 base64 数据,我想将它转换为 Asp.net 中的图像。我使用这个代码

byte[] data = Convert.FromBase64String(imageData);
var path = Server.MapPath("~/ImageFolder/") +  "AAA.jpeg";
System.IO.File.WriteAllBytes(path, data); //(*)

当代码到达第(*)行时,页面刷新,但我不想刷新。 base64转图片保存到文件夹不刷新页面的解决方法是什么?

如果我使用 MemoryStream,问题存在并且页面将刷新。

更新

我在客户端有这个代码

function ajaxCall(url, data, callBackFunction) {
    $.ajax({
        url: url,
        type: "POST",
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        data: data,
        success: function (response) {
            callBackFunction(response);
        },
        error: function (xhr, status, error) {
            alert(error);
        },
    });
}

    ajaxCall('/Default/Save/', {
 final: _final, // Some boolean flag
        imageData: imgData, // Image Base64
    }, function (response) {
        $('#resultDiv').html(response)
    });

并且在服务器中

[HttpPost]
    public ActionResult Save(bool final,string imageData)
    {
        var thumbHash = "";
        if (imageData.Length > 0)
        {
            try
            {
                imageData = imageData.Replace("data:image/jpeg;base64,", String.Empty);
                byte[] data = Convert.FromBase64String(imageData);
                thumbHash = "123456789ABC";
   var path = Server.MapPath("~/ImageFolder/") +  "AAA.jpeg";
              
                System.IO.File.WriteAllBytes(path, data); //(*)

            }
            catch (Exception ex)
            {
                thumbHash = "";
            }
        }

      
        if (final)
            return RedirectToAction("AddOne", "Cart", new { id = 12 });

      
        return Json( "Ahm" );
    }

问题已解决

代码没有任何问题。检查了很多之后,我找到了解决方案。 我只在 Visual Studio 中取消选中 'Enable Browser Link',问题就解决了。 感谢所有参与此问题的人。