C# .NET Checking if browser is mobile - what is the most reliable way?

后端 未结 5 1656
谎友^
谎友^ 2021-01-14 19:03

I know I can use Request.Browser.IsMobileDevice.

But does anyone know how it works, and if it is reliable and up to date?

Thanks!

相关标签:
5条回答
  • 2021-01-14 19:13

    You are looking for this. Put it in a folder in the App_Browsers folder. http://mdbf.codeplex.com/

    0 讨论(0)
  • 2021-01-14 19:14

    If you're going to use the latest and greatest features available you should take a look into the IE9 demo for Media Queries to make your decision by checking the current screen resolution.

    0 讨论(0)
  • 2021-01-14 19:19

    This question needed some 2018 love. Try this.

    if(Request.Browser.IsMobileDevice){
    // do something
    }
    

    You shouldn't need any @using statements for this, but if you did Intellisense would you tell and help you add it with a click.

    0 讨论(0)
  • 2021-01-14 19:22

    And if you need some more advance and mature, then try WURFL.

    0 讨论(0)
  • 2021-01-14 19:26

    You need to regularly update BrowserCaps to keep it up-to-date.

    http://www.asp.net/mobile/device-updates/instructions/

    Note: (Aug 25 2012) apparently the page has been removed.

    0 讨论(0)
提交回复
热议问题