1

I am trying to detect device through code but it's not working. However, my device based personalization is working fine. I've enabled device detection in config file already. I can see files under /app_data/devicedetection also. I am using below code to find the device:

var deviceProvider = FiftyOne.Foundation.Mobile.Detection.WebProvider.ActiveProvider;

        if (deviceProvider != null)
        {
            var result = deviceProvider.Match(Request.UserAgent);
            vm.IsMobile = result["IsMobile"].ToString().ToLower() == "true";
        }

I always get null in deviceProvider variable.

Are there any other approaches that I can follow to detect the device?

1
1

I've used below code and it's working fine:

 var deviceInfo = DeviceDetectionManager.GetDeviceInformation(Request.UserAgent);
  var myDevice = deviceInfo.DeviceType;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.