Shyjus.BrowserDetector
3.0.0-preview2
dotnet add package Shyjus.BrowserDetector --version 3.0.0-preview2
NuGet\Install-Package Shyjus.BrowserDetector -Version 3.0.0-preview2
<PackageReference Include="Shyjus.BrowserDetector" Version="3.0.0-preview2" />
paket add Shyjus.BrowserDetector --version 3.0.0-preview2
#r "nuget: Shyjus.BrowserDetector, 3.0.0-preview2"
// 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
- Browser detection
- Device type detection
- 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 | Versions 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. |
-
net6.0
- BrowserDetector.Abstractions (>= 1.0.0)
- BrowserDetector.Core (>= 1.0.0)
-
net7.0
- BrowserDetector.Abstractions (>= 1.0.0)
- BrowserDetector.Core (>= 1.0.0)
-
net8.0
- BrowserDetector.Abstractions (>= 1.0.0)
- BrowserDetector.Core (>= 1.0.0)
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/apevolo-api
.Net 8 、SqlSugar ORM、Vue 2.X、RBAC、前后端分离的开箱则用的企业级中后台权限管理系统
|
Version | Downloads | Last updated |
---|---|---|
3.0.0-preview2 | 245 | 1/2/2024 |
2.0.0 | 642,134 | 5/23/2021 |
1.1.1 | 225,859 | 2/19/2020 |
1.1.0 | 780 | 2/19/2020 |
1.0.9 | 1,047 | 1/24/2020 |
1.0.8 | 11,810 | 9/13/2019 |
1.0.7 | 544 | 9/7/2019 |
1.0.6 | 533 | 9/7/2019 |
1.0.5 | 539 | 8/31/2019 |
1.0.4 | 557 | 8/30/2019 |
1.0.3 | 566 | 8/30/2019 |
1.0.2 | 524 | 8/30/2019 |
1.0.1 | 530 | 8/30/2019 |
1.0.0 | 673 | 8/30/2019 |