Detect mobile device in ASP.NET Core

asp.net detect mobile device
asp.net get device information
asp net core httprequest useragent
asp net core 3 get user agent
how to detect mobile or desktop browser in javascript
asp.net core user agent parser
asp net core device fingerprint
asp net core detection

I have an application which uses mobile views and desktop views as different html pages. Now I am moving that to Asp.Net core. I am not thinking about Bootstrap due to some technical reasons. I have to detect the request is from Mobile or not in StartUp to load respective Layout page. How can I achieve that ? Looking for something similar to IsMobileDevice. Already tried MvcDeviceDetector 0.1.0-t00349acaa. It didn't worked as I am using .net version 4.6.1.

You can use the manual method outlined here: https://stackoverflow.com/a/13086894/1419970

Or you can use this library: http://www.nuget.org/packages/51Degrees.mobi/3.2.10.3-beta

Both will do for you.

To detect whether the request has come from mobile device or not in , Hi It it possible in Asp.Net core based Webapi project to detect if the user is on a mobile device? In previous version of Asp dotnet MVC it could� In this article, I will show an example on how to detect a mobile device in ASP.NET Web Forms. HttpCapabilitiesBase.IsMobileDevice Property gets a value indicating whether the browser is a recognized mobile device. true if the browser is a recognized mobile device; otherwise, false. The default is true.

I found great library. It's very easy to use. I am not sure is it 100% reliable, but it's covering all my cases.

Example:

    public class HomeController : Controller
    {           
        private readonly IDevice device;   

        public HomeController(IDeviceResolver deviceResolver)
        {                
            this.device = deviceResolver.Device
        }

        public IActionResult Index()
        {
            if(device.Type == DeviceType.Desktop)
            {
               //some logic
            }
            else if(device.Type == DeviceType.Mobile)
            {
               //some logic
            }
            else if(device.Type == DeviceType.Tablet)
            {
               //some logic
            }
        }
     }

Device detection .NET CORE

Thank you Wangkanai

Detect mobile device in ASP.NET Core - asp.net - html, Now I am moving that to Asp.Net core. I am not thinking about Bootstrap due to some technical reasons. I have to detect the request is from Mobile or not in� Detecting Mobile Phone Browser (Mobile Device) in ASP.Net using Regular Expression Each browser sends its information to the server using the HTTP_USER_AGENT server variable. The value of the User Agent variable is matched with two Regular Expressions.

Or you can use this free library DeviceDetector.NET.

This is a port of the popular PHP device-detector library to C#.

Here is how to use it.

DeviceDetectorNET.DeviceDetector.SetVersionTruncation(VersionTruncation.VERSION_TRUNCATION_NONE); 
var userAgent = Request.Headers["User-Agent"];
var result = DeviceDetectorNET.DeviceDetector.GetInfoFromUserAgent(userAgent);
var output = result.Success ? result.ToString().Replace(Environment.NewLine, "<br />") : "Unknown";

DeviceDetector.NET.NetCore 3.9.2.2, NetCore 3.9.2.2. The Universal Device Detection library for .NET that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars,� Detect mobile device in ASP.NET Core. Ask Question Asked 3 years, 7 months ago. Active 5 months ago. Viewed 15k times 4. 1. I have an application which uses mobile

wangkanai/Detection: ASP.NET Core Detection with , ASP.NET Core Detection with Responsive View for identifying details about client Responsive middleware for routing base upon request client device detection to specific view. Make your web app able to detect what client is accessing Device.Type == Device.Mobile) context.Response.WriteAsync("You are Mobile! How is it possible in Asp.Net 5 MVC 6 to detect if the user is on a mobile device? In previous version of Asp MVC it could be done like this: Request.Browser.IsMobileDevice The problem is that the namespace System.Web is not used by Asp.Net 5.

Detecting mobile device in ASP.Net and Node.js, In this blog, we will discuss and see how to detect mobile devices in asp.net and node.js. In summary, we recommend looking for the string “Mobi” anywhere in the User Agent to detect a mobile device. Like this: if (/Mobi/.test(navigator.userAgent)) { // mobile! } This will match all common mobile browser user agents, including mobile Mozilla, Safari, IE, Opera, Chrome, etc. Update for Android

Detect Mobile Browser (Mobile Device) in ASP.Net MVC, Here Mudassar Ahmed Khan has explained with an example, how to detect mobile phone browser (mobile device) in ASP.Net MVC Razor. I needed the ability to detect if a user was browsing from a mobile device or a normal web browser and redirect to the appropriate version of my site. I found very little ASP.NET tutorials that worked. So I decided to take a few different methods and language options I found on the net and put them into one simple ASP.NET method. Using the Code

Comments
  • There they suggest to use Bootstrap it seems. But as I said, I won't use it
  • please follow below link for the solutions. stackoverflow.com/a/61575500/10137052
  • Unable to resolve '51Degrees.mobi (>= 3.2.9.1)' for '.NETFramework,Version=v4.6.1'.
  • **Unable to resolve '51Degrees.mobi (>= 3.2.9.1)' for '.NETFramework,Version=v4.6.1'. ** This is the error I am getting when I tried 51degrees. It is not supporting .net version 4.6.1 I guess.
  • I guess it will give me a solution. Just I need to change the method to compact with .net core.
  • Can we check device globally and not in each controller or action? Actually I wanted to render mobile views for mobile device and desktop views for desktop device
  • I think it can be done in middleware on the same way.