does microsoft browser link work for api projects?

First, Browser Link is disabled by default in Visual Studio. Before using it, please remember to enable it first.

Second, check how the Microsoft Browser Link works:

Browser Link uses SignalR to create a communication channel between Visual Studio and the browser. When Browser Link is enabled, Visual Studio acts as a SignalR server that multiple clients (browsers) can connect to. Browser Link also registers a middleware component in the ASP.NET Core request pipeline. This component injects special <script> references into every page request from the server. You can see the script references by selecting View source in the browser and scrolling to the end of the <body> tag content:

   <!-- Visual Studio Browser Link -->
   <script type="application/json" id="__browserLink_initializationData">
   <script type="text/javascript" src="http://localhost:54139/b6e36e429d034f578ebccd6a79bf19bf/browserLink" async="async"></script>
   <!-- End Browser Link -->

For the WebAPI application, since it doesn’t return the web page with above <script> script. The Browser Link can’t detect the web API return data. So, in the Browser Link Dashboard, the API application keeps showing “no current connections” and Microsoft Browser Link not work for API projects (You could also click the “View in Browser” in the Dashboard, it will return a web page with 404 error).

To use Microsoft Browser Links, you could try to change the application to ASP.NET Core Razor Pages or MVC projects, then, the result like this:

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top