Skip to content

Detect browsers using user agent strings in .NET. Inspired by Bowser.

License

Notifications You must be signed in to change notification settings

BigBadBleuCheese/Kong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kong

Detect browsers using user agent strings in .NET. Inspired by Bowser.

What is this for?

This library can be used to detect the characteristics of a web browser by examining the value of its HTTP request User-Agent header.

How to use

Step 1: Install the NuGet package

You can either use the Package Manager Console:

Install-Package Epiforge.Kong

Or use the NuGet Package Manager to install Epiforge.Kong as a NuGet package in your project.

Step 2: Create instances of the Browser class with User-Agent header values

Example in a Microsoft Web API controller:

using System.Web.Http;

public class ExampleController : ApiController
{
    [HttpGet, Route("isMobile")]
    public IHttpActionResult IsMobile()
    {
        // Return true if the caller is a mobile browser; otherwise, false.
        return Ok(new Kong.Browser(string.Join(" ", Request.Headers.GetValues("User-Agent"))).Mobile);
    }
}

Example in a Microsoft SignalR hub:

using Microsoft.AspNet.SignalR;

public class ExampleHub : Hub
{
    public bool IsMobile()
    {
        // Return true if the connected client is a mobile browser; otherwise, false.
        return new Kong.Browser(string.Join(" ", Context.Request.Headers.GetValues("User-Agent"))).Mobile;
    }
}

License

MIT License

About

Detect browsers using user agent strings in .NET. Inspired by Bowser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages