0

In the database I use a column of datatype varbinary(max) to save an image, but when I load the image, I get a timeout.

public async Task<byte[]> UploadImage(IFormFile req)
{
    using var ms = new MemoryStream(16 * 1024);
    await req.CopyToAsync(ms);

    byte[] result = ms.ToArray();

    ms.Close();
    ms.Dispose();

    return result;
}

public string RetrieveImage(byte[] data)
{
    return string.Format("data:image/png;base64,{0}", Convert.ToBase64String(data, 0, data.Length));
}

I tried to find out but it keeps giving error

An unhandled exception occurred while processing the request.
Win32Exception: The wait operation timed out.
Unknown location

SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action wrapCloseInAction)

Data displayed in SQL Server is <Binary data>

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Duy
  • 1
  • 1

0 Answers0