Recently i created a mobile browser compatible website for our existing Website.
So as we already marketed our website well for desktop browser but not for Iphone or other Mobile device so we started doing that. Now what client want that whenever any person open our website on mobile device it will redirect to Iphone compatible website
So what, I Just write these lines of code:
if (HttpContext.Current.Request.Browser.IsMobileDevice || HttpContext.Current.Request.UserAgent.ToLower().Contains("iphone"))
{
Response.Redirect("http://iphone.domain.com");
}
on the above code Line
HttpContext.Current.Request.Browser.IsMobileDevice detects the mobile devices but as our Iphone not detected through that so thats why i add one more line :
HttpContext.Current.Request.UserAgent.ToLower().Contains("iphone")
Which detects the Iphone you can use this one for other mobile device not supported by .NET
Great tip. Was wondering how to get my iPhone to move over to the isMobileDevice "if"-clause.
ReplyDeleteThank you.