问题
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