You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been spending quite a lot of time trying to turn this class into a simple service I can inject on my page and call "IsMobile".
It's really not that simple with the current documentation. None of the code here is structured for Dependency Injection in ASP.NET.
It requires proper caching or can cause some performance issues. What's the proper way of setting up caching with dependency injection in ASP.NET? The comment here states that static cache isn't the best here; and just creating a new cache on every request is pointless. The cache must be created and configured only once for the duration of the app.
// OPTIONAL: Set caching method
// By default static cache is used, which works best within one php process (memory array caching)
// To cache across requests use caching in files or memcache
// add using DeviceDetectorNET.Cache;
dd.SetCache(new DictionaryCache());
The comment also points to LRUCachedDeviceDetector.GetDeviceDetector(userAgent); which behaves completely different from the line above. SetCache makes the DeviceDetector work with a cache; but this line (maybe?) returns a DeviceDetector from a cache, with no clientHints.
If all I need is to know whether the user is a mobile device, the caching should be used too?
What I need is to be able to put @inject DeviceDetector DeviceDetector on a page and @if (DeviceDetector.IsMobile(Request)) on the page with no further complications. I shouldn't have to spend hours trying to figure it out.
The text was updated successfully, but these errors were encountered:
I've been spending quite a lot of time trying to turn this class into a simple service I can inject on my page and call "IsMobile".
It's really not that simple with the current documentation. None of the code here is structured for Dependency Injection in ASP.NET.
It requires proper caching or can cause some performance issues. What's the proper way of setting up caching with dependency injection in ASP.NET? The comment here states that static cache isn't the best here; and just creating a new cache on every request is pointless. The cache must be created and configured only once for the duration of the app.
The comment also points to
LRUCachedDeviceDetector.GetDeviceDetector(userAgent);
which behaves completely different from the line above. SetCache makes the DeviceDetector work with a cache; but this line (maybe?) returns a DeviceDetector from a cache, with no clientHints.If all I need is to know whether the user is a mobile device, the caching should be used too?
What I need is to be able to put
@inject DeviceDetector DeviceDetector
on a page and@if (DeviceDetector.IsMobile(Request))
on the page with no further complications. I shouldn't have to spend hours trying to figure it out.The text was updated successfully, but these errors were encountered: