Can anyone help? I want to use the free service from 51Degrees not the Lite version however the Cloud API (https://51degrees.com/compare-data-options).
I am trying to set my Global.asax to have a display mode for "tablet" and "mobile" so I can use:
- index.cshtml
- index.tablet.cshtml
- index.mobile.cshtml
The following works when not using 51 Degrees. Has anyone got an example how to integrate the 51 Degrees Cloud API with the global.asax to filter for tablet/mobile.
https://51degrees.com/Support/Documentation/APIs/Cloud-API/NET-Cloud
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Tablet")
{
ContextCondition = (ctx =>
ctx.Request.UserAgent.IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0 ||
ctx.Request.UserAgent.IndexOf("Android", StringComparison.OrdinalIgnoreCase) >= 0 &&
ctx.Request.UserAgent.IndexOf("Mobile", StringComparison.OrdinalIgnoreCase) <= 0
)
});
Thanks Tommy
You can get the value of DeviceType which can be Desktop, SmartPhone or Tablet (plus a few other things) by using the first C# example on the page you linked. Something like:
Then your condition for tablet would be:
You can query the possible values of DeviceType with the URL
or alternatively, use the IsMobile, IsSmartPhone, IsTablet and IsDesktop properties which return true or false.