fullstackhero / dotnet-starter-kit

Production Grade Cloud-Ready .NET 8 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
https://fullstackhero.net/dotnet-webapi-boilerplate/
MIT License
5.05k stars 1.51k forks source link

Blazor Debug, Breakpoints not being hit. #1011

Open kallievz opened 2 weeks ago

kallievz commented 2 weeks ago

Not sure if it is project related, or my ide, but seems when launching via aspire the breakpoints in Blazor is not being hit due to symbols not being loaded. FSH.Blazor not even showing up in debug/modules in order to set loading of symbols.

I can hit the Blazor Breakpoints in V1.

There is a unauthoirised exception i am trying to pinpoint everytime i log into V2 after login button event, but cant trap it due to debug not working. I can somehow figure out that it might be the profile-picture, as it is not rendering.

Seems to be related to SO post https://stackoverflow.com/questions/76890354/why-visual-studio-2022-dont-go-to-breakpoint-razor-file-in-blazor-wasm-or-ho

iammukeshm commented 2 weeks ago

@kallievz I have added a small fix related to this. Can you please pull the latest from main branch and test this if your problem is solved?

kallievz commented 2 weeks ago

Hi @iammukeshm , is this for Blazor Debug, or the unauth exception?

iammukeshm commented 2 weeks ago

@kallievz it's for the Blazor Debug. I dont seem to have any Auth related issue.

kallievz commented 2 weeks ago

Hi @iammukeshm , running project now launch the browser, it hit the breakpoint once, and errors out with Unauth exception. Brower launches on different port as configured in appsetting.json, and seems to change everytime the project run. Using the one that start up from Aspire does not hit breakpoint. Is there a way to add Cors with only localhost instead of specifying port? If it was just localhost, it would work, but now the port is set dynamically everytime project run,

iammukeshm commented 2 weeks ago

@kallievz so the blazor app is set to run on 7100 port. If this port is already in use, it would re-assign to a random port, which i think is happening in your case. Do check if the port is in use.

Else, as a work around, you can disable CORS.

Open up namespace FSH.Framework.Infrastructure.Cors.Extensions and edit the following, just add .AllowAnyOrigin()

internal static IServiceCollection AddCorsPolicy(this IServiceCollection services, IConfiguration config)
{
    var corsOptions = config.GetSection(nameof(CorsOptions)).Get<CorsOptions>();
    if (corsOptions == null) { return services; }
    return services.AddCors(opt =>
    opt.AddPolicy(CorsPolicy, policy =>
        policy.AllowAnyHeader()
            .AllowAnyMethod()
            .AllowAnyOrigin()));
}
kallievz commented 2 weeks ago

It could be a workaround, but would prefer to use Cors policy. A bit paranoid about unauthed access. I dont want to open that door, but for a dev environment i could prob do it.

It is being used already by Aspire Blazor app. So it seems it is spinning up the Blazor app twice, and linking debugger to the new one not configured on port 7100, almost like 2 Blazor instances running, and one being linked.