在ASP.NET Core中检测移动设备 [英] Detect mobile device in ASP.NET Core

查看:203
本文介绍了在ASP.NET Core中检测移动设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用移动视图和桌面视图作为不同html页面的应用程序.现在,我将其移至Asp.Net核心.由于某些技术原因,我没有考虑Bootstrap.我必须在启动中检测到请求来自移动设备还是不在移动设备中,以加载相应的布局页面.我该如何实现?寻找类似于IsMobileDevice的东西.已经尝试 MvcDeviceDetector 0.1.0-t00349acaa .由于我使用的是.net 4.6.1版,因此无法正常工作.

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.

推荐答案

您可以使用此处概述的手动方法: https://stackoverflow.com/a/13086894/1419970

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

或者您可以使用此库: http://www. nuget.org/packages/51Degrees.mobi/3.2.10.3-beta

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

两者都会为您服务.

这篇关于在ASP.NET Core中检测移动设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆