1

我是 asp.net C# 的新手。

我正在为移动用户创建一个网站。

我想将页面重定向到用户移动版本及其平台。

我不想使用WURFL

还有这个http://51degrees.codeplex.com/

有没有其他可能的方法来为不同的移动用户创建页面?

例如android(冰淇淋)和android(姜饼)等的不同页面......

4

2 回答 2

2

像这样使用Request.UserAgent

if(Request.UserAgent.Contains("Android"))
{
    Response.Redirect("Andriod/MyPage.aspx");
}

版本检查也可以以相同的方式完成。所有流行的操作系统/浏览器的用户代理都可以在互联网上获得。

于 2012-08-17T07:32:05.880 回答
1

您可以使用 JavaScript 导航器。像这样的东西:

p = navigator.platform;

// Detects if it is an iOS device
if( p === 'iPad' || p === 'iPhone' || p === 'iPod' ){
    //iOS = true;
    //Redirect
}

// Detects if it is an Android device
if(p.indexOf("android")>=0);
    //Android= true;
    //Redirect
}

或者

var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
if(iOS)
    //Redicret
于 2012-08-17T07:20:39.750 回答