20

Before you go crazy: Yes, this is a duplicate of this, this, this, and this. Probably a lot more, but these were the first results when searching.

I'm running VS 2022 Preview 5.0, I've created a Blazor WASM project, and I've tried every single suggestion I could find to stop VS from opening a new browser but instead open in a tab. I'm also running Windows 11, which might cause some weird issues with "default apps", but I did check and all my .html, HTTP, HTTPS, etc. links are set to open in Google Chrome.

Here is a video showing that I already have Chrome open, I have disabled Stop debugger when browser window is closed, close browser when debugging stops and Enable JavaScript debugging for ASP.NET (Chrome, Edge and IE): https://i.imgur.com/azLDram.mp4

I also tried enabling both, saving, disabling them again, and then saving.

Did Microsoft introduce a new 3rd thing that might cause this to happen, or am I just running a bugged version of Visual Studio?

EDIT: I just completely removed VS 2022 Preview 5.0 and installed VS 2022 17.0.5 (not Preview), and the problem still occurs.

EDIT 2: When I hit CTRL + F5 it opens a new tab in my existing Chrome window (as expected), but I want debugging at some point. This is so weird.

EDIT 3:

I found a possible solution, but there is a downside to it.

launchSettings.json has an inspectUri:

{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:57110", "sslPort": 0 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } } 

If I remove that inspectUri property, it will open a new tab instead of a window. However, none of my debug symbols are loaded, which means I can't set a breakpoint and debug the code. The symbols are loaded if I keep the launchUri and I use the Chrome window instead.

If I then keep the window open, but I open the URL in my regular Chrome window, I still cannot debug. Debugging only works if I use the window Visual Studio opens for me. I guess this is intentional for Blazor WASM projects, but it is really annoying.

1

1 Answer 1

26

turning off this setting worked for me

enter image description here

Sign up to request clarification or add additional context in comments.

6 Comments

Confirmed this works in 2024 with latest VS and Firefox.
Great, but now it opens a new tab every time I start debugging.
@DaveVandenEynde I don't think it's related to this setting, you can open launchSettings.json and change launchBrowser to false. Then it won't open the tab
@kurdemol94 yes, it does. I do want the tab to open, but it will open in the main browser as I wanted, not in a separate window. It will also not close the tab if I stop debugging, or stop debugging if I close the tab. But it won't know the tab is still open when I restart the application, which is a bummer. It has to do with how it keeps track of the tab. I think it keeps an eye on the process id of the new window, and detects that that process has finished. It can't track a single tab inside a window.
@DaveVandenEynde I don't think VS tracks the tab at all. LaunchBrowser setting will simply launch a new tab every time you start the project. I personally have launchBrowser set to true and I just close new tabs if I want to keep working on the old one.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.