validide / mobile-detect

A .Net port of https://github.com/serbanghita/Mobile-Detect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mobile-detect

About

A simple C# library to detect if the request is from a mobile device

This is based on the PHP version Mobile-Detect (the current version has limited functionality compared to the original).

Status

Codacy Badge Coverage Status Tests Nuget

Usage

/* Removed usings */
using MobileDetect.Implementations;
using MobileDetect.MatchingRules;

namespace WebApplication.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            var detector = new MobileDetector(DefaultRules.Instance, Request.Headers);
            var isMobile = detector.IsMobile(); //this is true is the request originates from a mobile phone or tablet
            var isTablet = detector.IsTablet(); //this is true is the request originates from a tablet

            /* Do some stuff */

            return View();
        }
    }
}

About

A .Net port of https://github.com/serbanghita/Mobile-Detect

License:MIT License


Languages

Language:C# 70.6%Language:Smalltalk 20.4%Language:PowerShell 9.0%