How to get Requested browser name and version in asp.net core 2.0

Solution 1:

Use install-package Wangkanai.Detection -pre and install-package Wangkanai.Detection.Browser -pre in PM to install package. Then... Write the following code in Startup.cs:

services.AddDetection();
services.AddDetectionCore().AddBrowser();

In your Controller:

private readonly IDetection _detection;
        public HomeController(IDetection detection)
        {
            _detection = detection;
        }
public IActionResult Index()
        {
            string browser_info = _detection.Browser.Type.ToString() + _detection.Browser.Version;
            ViewData["a"] = browser_info;
            return View(_detection);
        }