Enabling Visual Studio’s Browser Link feature in ASP.NET Core web applications

Posted: (EET/GMT+2)

 

Visual Studio supports a feature called Browser Link that allows two-way communication between your web browser you use to test your ASP.NET web applications and Visual Studio. For example, Visual Studio can automatically reload the web page on the browser, if your application changes. This is especially useful if you use multiple browsers to test.

To enable browser link from your ASP.NET Core code, you'd call the method "app.UseBrowserLink()" from within your applications startup class. More specifically, you'd add the call to the following method:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)

This would enable browser link for your application. Of course, it is possible to limit this feature to debug builds only, which is of course wise. You don't want to enable browser link in release/production builds.