Browser Link in ASP .NET Core

What is Browser Link?

Browser Link is a feature in Visual Studio that creates a communication channel between the development environment and one or more web browsers. You can use Browser Link to refresh your web application in several browsers at once, which is useful for cross-browser testing.

How Does It Work?

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 an HTTP module with ASP.NET. This module injects special <script> references into every page request from the server. You can see the script references by selecting “View source” in the browser.

https://docs.microsoft.com/en-us/aspnet/visual-studio/overview/2013/using-browser-link/_static/image13.png

Your source files are not modified. The HTTP module injects the script references dynamically.

Because the browser-side code is all JavaScript, it works on all browsers that SignalR supports, without requiring any browser plug-in.

Earlier Discussion

We discussed about the browser link in .Net Framework earlier.

Take a look at here:

Browser Link option in Visual Studio

BrowserLink in ASP .NET Core

To use BrowserLink in ASP .NET Core, we should do few tweaks in the source code.

Install the following package in your project

Microsoft.VisualStudio.Web.BrowserLink

Or using packet manager

Install-Package Microsoft.VisualStudio.Web.BrowserLink -Version 2.2.0

And config BrowserLink in your startup.cs

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
    app.UseBrowserLink();
}

Start using

Now start using the BrowserLink from the tool bar dashboard

Happy Coding!

Minimalism in programming

Minimalism is the new dope in the real world.

Here is the few minimalist approach you can follow in the world of programming.

DRY – don’t repeat yourself

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

KISS – Keep it simple, stupid

The simplest explanation tends to be the right one.

Yagni – You Aren’t Gonna Need It

The art of saying No. Don’t build everything customer/manager ask. Think more than twice and analyse before building a feature & importance of its existence.

Break the number of lines

Break the number of lines in coding when it exceeds N number of characters (mostly to fit in small or medium size screens).

Use access specifiers

Use access specifiers public or private whenever applicable – to avoid unnecessary flow of data here and there.

Naming Conventions

Do proper naming for class, method or variables. Prepare standard naming conventions which suits you.

Version Control System

Choose the right version control if you are doing collaborative work.

Don’t comment the unused code

Don’t comment out any code for future reference – just delete it – if have version control, you can get at any point of time. Or tag the commit for quick access.

Make Abstraction

Reuse the component if possible. Don’t copy paste the entire method just to change one section of the code. Think how you can handle it.

To get latest updates you can follow or subscribe! #peace