Reputation: 51
I'm new in asp.net C#.
I am creating a website especially for mobile users.
I want to redirect the page to the user mobile version and its platform.
I don't want to use WURFL
and also this http://51degrees.codeplex.com/
Are there any other possible way to create the pages for different mobile users?
For example different pages for android (ice cream) and android (gingerbread) etc...
Upvotes: 1
Views: 416
Reputation: 17724
Use this Request.UserAgent
like this:
if(Request.UserAgent.Contains("Android"))
{
Response.Redirect("Andriod/MyPage.aspx");
}
Version checking too can be done the same way. User agents for all popular Os / browsers are readily available on the internet.
Upvotes: 2
Reputation: 1563
You can use the JavaScripts Navigator. Something like this:
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
}
or
var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
if(iOS)
//Redicret
Upvotes: 1