Jason D
Jason D

Reputation: 2087

How to stop page from reloading when debugging a Blazor server application

When I set breakpoints and try to step through my Blazor server application, I encounter a very annoying issue. If I do not quickly step through and debug my problem, when I hit F5 to continue running the application, the page reloads in the browser.

I assume this is happening because the SignalR connection between the browser and my application is temporarily broken while I am sitting at a breakpoint.

Is there any workaround for this? It makes the debugging experience pretty terrible.

Upvotes: 0

Views: 346

Answers (1)

Jason D
Jason D

Reputation: 2087

Nearly one year later, I found a solution for this. I was able to set SignalR hub options as shown below:

public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers();
        services.AddRazorPages().AddNewtonsoftJson();

        if (CurrentEnvironment.IsDevelopment())
        {
            services.AddServerSideBlazor()
                        .AddHubOptions(options =>
                        {
                            options.ClientTimeoutInterval = TimeSpan.FromSeconds(180);
                        });
        }
        else
        {
            services.AddServerSideBlazor();
        }
...

Upvotes: 1

Related Questions