I have developed a website using asp.net web developer 2010. I would like to redirect to different page if the site is accessed from mobile browser. And, different functionality for windows/mac/linux etc users.
How can I do this?
I referred some posts in some forums, and it is said that I need to depend on third party libraries.
How could I implement this without any third party libraries?
Any one Please help me out.
Any help is appreciated. Thanks!!
The Request.Browser object properties are probably where it is at, these are all options that may be useful to you:
Request.Browser.IsMobileDevice
Request.Browser.MobileDeviceManufacturer
Request.Browser.MobileDeviceModel
Request.Browser.ScreenPixelsWidth
Request.Browser.SupportsXmlHttp
Was there a reason you wanted to avoid a 3rd party component?
We currently use a WURFL device database via 51Degrees.mobi - which works really well.
You can use useragent in asp.net to verify the request are coming from mobile or desktop.
protected override void OnInit(EventArgs e)
{
string userAgent = Request.UserAgent;
if (userAgent.Contains("BlackBerry")
|| (userAgent.Contains("iPhone") || (userAgent.Contains("Android"))))
{
//add css ref to header from code behind
HtmlLink css = new HtmlLink();
css.Href = ResolveClientUrl("~/mobile.css");
css.Attributes["rel"] = "stylesheet";
css.Attributes["type"] = "text/css";
css.Attributes["media"] = "all";
Page.Header.Controls.Add(css);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With