How do I detect mobile devices in blazor server side application?

安稳与你 提交于 2021-02-10 18:29:26

问题


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?

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


回答1:


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/



来源:https://stackoverflow.com/questions/62270247/how-do-i-detect-mobile-devices-in-blazor-server-side-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!