ASP.NET application server does not respond

MOON 20 Reputation points
2024-01-31T09:15:46.54+00:00

I bind model data into my Razor Page. The page is successfully loaded, then the server gets locked. When I submit any request to ASP.NET, it does not reply me. Moreover, it does not refresh the page. This occurs when model data have an image coded via 64 number base. How could we prevent locking?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,400 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,363 questions
{count} votes

2 answers

Sort by: Most helpful
  1. AgaveJoe 27,696 Reputation points
    2024-01-31T21:25:00.92+00:00

    Your design is a little confusing. I think the intent is to display a Base64 image using an image tag in a Razor Page.

    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    
    namespace RazorPagesDemo.Pages
    {
        public class IndexModel : PageModel
        {
            private IWebHostEnvironment _env;
            private readonly ILogger<IndexModel> _logger;
    
            public IndexModel(ILogger<IndexModel> logger, IWebHostEnvironment env)
            {
                _logger = logger;
                _env = env;
            }
    
    
            internal string Base64Image { get; set; } = string.Empty;
    
            public void OnGet()
            {
                //Get a base64 image
                byte[] bytes = System.IO.File.ReadAllBytes($"{_env.WebRootPath}/images/lespaul.png");
                Base64Image = Convert.ToBase64String(bytes);
            }
        }
    }
    
    

    The Razor

    @page
    @model IndexModel
    @{
        ViewData["Title"] = "Home page";
    }
    
    <div class="text-center">
        <img src="data:image/png;base64, @Model.Base64Image" alt="Les Paul" />
    </div>
    
    

  2. MOON 20 Reputation points
    2024-02-03T09:49:42.85+00:00

    I think the system is overloaded with data which come from database management system due to the fact that decrease of image resolution solves the problem.