How do I check if the useragent is an ipad or iphone?

前端 未结 9 2556
礼貌的吻别
礼貌的吻别 2020-12-09 14:42

I\'m using a C# asp.net website.

How can I check if the user using ipad or iphone? How can I check the platform?

For example, if the user enter the websi

9条回答
  •  一个人的身影
    2020-12-09 15:18

    you can do it by getting the UserAgent

    string ua = Request.UserAgent;
    if (ua != null && (ua.Contains("iPhone") || ua.Contains("iPad")))
    {
    ...
    ...
    ...
    }
    

提交回复
热议问题