Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Debug, Breakpoints not being hit. #1011

Open
kallievz opened this issue Aug 26, 2024 · 6 comments
Open

Blazor Debug, Breakpoints not being hit. #1011

kallievz opened this issue Aug 26, 2024 · 6 comments

Comments

@kallievz
Copy link
Contributor

kallievz commented Aug 26, 2024

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

@fullstackhero fullstackhero deleted a comment Aug 26, 2024
@iammukeshm
Copy link
Member

@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
Copy link
Contributor Author

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

@iammukeshm
Copy link
Member

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

@kallievz
Copy link
Contributor Author

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
Copy link
Member

iammukeshm commented Aug 28, 2024

@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()));
}

@iammukeshm iammukeshm reopened this Aug 28, 2024
@kallievz
Copy link
Contributor Author

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.

Mike6x pushed a commit to Mike6x/dotnet-starter-kit that referenced this issue Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants