Search code examples
asp.net-core.net-6.0visual-studio-2022

Is It Possible To Launch 2 Browser Tabs With Different Urls When Debugging in Visual Studio 2022?


I have a .NET 6 web API project that uses Hangfire in the background. When I debug the project from VS2022 I would like to open both the swagger UI and the Hangfire dashboard in separate tabs when the browser is launched. Is there any way to accomplish this within launch profiles or elsewhere?

I tried adding multiple Url's to the Url setting within launch profiles for the project (note NOT App Url). That seemed like the logical place to do it, but it didn't work.


Solution

  • You can implement this feature by using .bat file like below.

    open_another_page.bat

    Find the port num from launchSettings.json file.

    @echo off
    timeout /t 5
    start "" "https://localhost:7075/Home/Privacy"
    

    Add below setting in your .csproj file.

    <Target Name="PostBuild" AfterTargets="Build">
        <Exec Command="&quot;$(ProjectDir)open_another_page.bat&quot;" />
    </Target>
    

    And we need to change post-build event settings to Always.

    enter image description here

    Screenshots in my side

    enter image description here

    enter image description here