You must Sign In to post a response.
  • Category: .NET

    How can i detect on which device[phone,tablet,desktop] type is application running?

    how can i detect on which device[phone,tablet,desktop] type is application running? C#
  • #768787
    Hi,

    We have two pre-build function for it which returns the bool value to understand which platform we are running on.

    For Desktops

    public static bool IsDesktopWindows
    {
    get { return Environment.OSVersion.Platform != PlatformID.WinCE; }
    }



    For android Mobiles


    public static bool IsWindowsCE
    {
    get { return Environment.OSVersion.Platform == PlatformID.WinCE; }
    }


    For Windows based Mobile and tabs

    public static bool IsWindowsMobileStandard
    {
    get
    {
    return IsWindowsCE()
    && (NativeMethods.GetPlatformType() == "SmartPhone");
    }
    }

    public static bool IsWindowsMobileProfessional
    {
    get
    {
    return IsWindowsCE()
    && (NativeMethods.GetPlatformType() == "PocketPC");
    }
    }


    Thanks,
    Mani

  • #768803
    Hai Rathimaran,
    Environment class under System namespace describes about various environment related classes, methods and properties which can be used to get the details about the current OS, Platform, Browser etc.
    Environment.OSVersion will give the OS which is running in the current device.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #768807
    Hi Rathimaran,

    If you want to identify the device which the application is running then you have to get the request type first then check the condition what type of device it is.

    Ex:

    WURFLRequest wurflRequest = WURFLRequestFactory.CreateRequest(HttpContext.Current.Request);

    if(wurflRequest.IsDesktopRequest)
    return;


    In the same passion you have to check other conditions tooo....

    Refer below link to understand better on the same.

    stackoverflow.com/questions/7034697/how-can-i-detect-if-the-request-is-coming-from-a-mobile-browser-in-my-asp-net-mv

    Hope this helps you....

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #768813
    Thanks guys.... its use full for me......


  • Sign In to post your comments