Shyjus.BrowserDetector 3.0.0-preview2

This is a prerelease version of Shyjus.BrowserDetector.
dotnet add package Shyjus.BrowserDetector --version 3.0.0-preview2                
NuGet\Install-Package Shyjus.BrowserDetector -Version 3.0.0-preview2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shyjus.BrowserDetector" Version="3.0.0-preview2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Shyjus.BrowserDetector --version 3.0.0-preview2                
#r "nuget: Shyjus.BrowserDetector, 3.0.0-preview2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Shyjus.BrowserDetector as a Cake Addin
#addin nuget:?package=Shyjus.BrowserDetector&version=3.0.0-preview2&prerelease

// Install Shyjus.BrowserDetector as a Cake Tool
#tool nuget:?package=Shyjus.BrowserDetector&version=3.0.0-preview2&prerelease                

BrowserDetector

Browser detection capabilities for asp.net core.

This library does

  1. Browser detection
  2. Device type detection
  3. Operating System detection

For browser detection in Azure Functions .NET Isolated, check Shyjus.BrowserDetector.AzureFunctions package.

Getting started

Step 1: Install the BrowserDetector nuget package

Install-Package Shyjus.BrowserDetector

Step 2: Enable the browser detection service by calling AddBrowserDetection method on IServiceCollection in your startup code.

services.AddBrowserDetection();

Step 3: Inject IBrowserDetector to your controller class or view file or middleware and access the Browser property.

Example usage in controller code

public class HomeController : Controller
{
    private readonly IBrowserDetector browserDetector;
    public HomeController(IBrowserDetector browserDetector)
    {
        this.browserDetector = browserDetector;
    }
    public IActionResult Index()
    {
        var browser = this.browserDetector.Browser;
        // Use browser object as needed.

        return View();
    }
}

Example usage in view code

@inject Shyjus.BrowserDetection.IBrowserDetector browserDetector

<h2> @browserDetector.Browser.Name </h2>
<h3> @browserDetector.Browser.Version </h3>
<h3> @browserDetector.Browser.OS </h3>
<h3> @browserDetector.Browser.DeviceType </h3>

Example usage in custom middleware

You can inject the IBrowserDetector to the InvokeAsync method.

public class MyCustomMiddleware
{
    private RequestDelegate next;
    public MyCustomMiddleware(RequestDelegate next)
    {
        this.next = next;
    }
    public async Task InvokeAsync(HttpContext httpContext, IBrowserDetector browserDetector)
    {
        var browser = browserDetector.Browser;

        if (browser.Type == BrowserType.Edge)
        {
            await httpContext.Response.WriteAsync("Have you tried the new chromuim based edge ?");
        }
        else
        {
            await this.next.Invoke(httpContext);
        }
    }
}

Interpreting the Name value returned by IBrowser.Name

  • Firefox - Firefox browser.
  • EdgeChromium - The new Chromium based Microsoft Edge browser.
  • Edge - The legacy Edge browser.
  • Safari - The Safari browser.
  • Chrome - The Chrome browser.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Shyjus.BrowserDetector:

Package Downloads
MosFlightWidget.Helper

Package Description

SeedBt.Library.Core

Package Description

MosFlightWidgetHelper

Package Description

Yaroslav08.Extensions

Package Description

LogusBrain.Core

An easy to use library with all the features you need.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Shyjus.BrowserDetector:

Repository Stars
xianhc/ape-volo-admin
.Net 8 、SqlSugar ORM、Vue 2.X、RBAC、前后端分离的开箱则用的企业级中后台权限管理系统
Version Downloads Last updated
3.0.0-preview2 252 1/2/2024
2.0.0 660,330 5/23/2021
1.1.1 230,891 2/19/2020
1.1.0 785 2/19/2020
1.0.9 1,057 1/24/2020
1.0.8 11,872 9/13/2019
1.0.7 549 9/7/2019
1.0.6 538 9/7/2019
1.0.5 544 8/31/2019
1.0.4 562 8/30/2019
1.0.3 571 8/30/2019
1.0.2 528 8/30/2019
1.0.1 534 8/30/2019
1.0.0 687 8/30/2019