Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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).

Usage

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

namespace WebApplication.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            var headers = Request.Headers.ToDictionary(k => k.Key, v => v.Value.ToString());
            var detector = new MobileDetector(DefaultRules.Instance, 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();
        }
    }
}
You can’t perform that action at this time.