如何在blazor服务器端应用程序中检测移动设备? [英] How do I detect mobile devices in blazor server side application?

查看:75
本文介绍了如何在blazor服务器端应用程序中检测移动设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检测我的blazor服务器端应用程序的用户是否正在使用移动设备.有什么方法可以找出用户使用的设备吗?

I need to detect if the user of my blazor server side application is using a mobile device. Is there any way to find out which device the user is using?

我知道我可以使用JSRuntime做到这一点,但是有什么办法可以通过纯C#来解决它?

I know I can do it with a JSRuntime but is there any way to figure it out with pure C#?

推荐答案

我确实找到了这篇文章,可以阅读Blazor中一个窗口的宽度和高度.看起来它使用了JS Interop.这样,您可以根据其分辨率的宽度确定用户是否正在使用手机.当然,这并不是100%完全的证明,因为桌面上的某人可以将其窗口大小调整为移动分辨率. https://blazor.tips/blazor-how-to-ready-window-dimensions/

I did find this article that will read you the width and height of a window in Blazor. Looks like it uses JS Interop. With that, you can determine if a user is using a mobile based on the width of their resolution. Of course, it's not 100% full proof as someone on a desktop can resize their window down to a mobile resolution. https://blazor.tips/blazor-how-to-ready-window-dimensions/

这篇关于如何在blazor服务器端应用程序中检测移动设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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