blog

Home / DeveloperSection / Blogs / Mobile support in asp.net 4.0

Mobile support in asp.net 4.0

Anonymous User4941 21-May-2011

Some common properties which is useful while you are developing mobile devices using asp.net 4.0

1)      Detect it is mobile device or not: We can use Request.Browser.IsMobileDevice property to check source of request that it is coming from Mobile device or by computer. This property is useful when we develop such type of application which is accessible by mobile devices as well as computers.

2)      Retrieving mobile device manufacture: We can use Request.Browser.MobileDeviceManufacture to retrieve device manufacture name.

3)      Retrieving mobile device model: We can use Request.Browser.MobileDeviceModel to retrieve mobile device model name.

4)      Retrieve screen pixel width : We can retrieve mobile screen width by using Request.Browser.ScreenPixelsWidth property to retrieve width of mobile screen.

Example which represent these properties  

protected void Page_Load(object sender, EventArgs e)
{
        if (Request.Browser.IsMobileDevice)   //Check whether request comes from mobile device
        {
            Response.Write("This request comes from mobile device.");
            Response.Write("Mobile device manufacture   :  " + Request.Browser.MobileDeviceManufacturer + "<br />");    //Writing mobile device manufacture.
            Response.Write("Mobile device model  :  " + Request.Browser.MobileDeviceModel + "<br />");         //Writing mobile device model name.
            Response.Write("Screen Width  :  " + Request.Browser.ScreenPixelsWidth + "<br />");               //Writing screen pixel width.
            Response.Write("Screen Height  :   " + Request.Browser.ScreenPixelsHeight + "<br />");            //Writing screen pixel height.
        }
}


Updated 18-Sep-2014
I am a content writter !

Leave Comment

Comments

Liked By