Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving documentation #83

Open
mysteryx93 opened this issue Sep 2, 2024 · 0 comments
Open

Improving documentation #83

mysteryx93 opened this issue Sep 2, 2024 · 0 comments
Labels
detection improvements Pull requests that update a dependency file enhancement New feature or request

Comments

@mysteryx93
Copy link

mysteryx93 commented Sep 2, 2024

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.

@totpero totpero added enhancement New feature or request detection improvements Pull requests that update a dependency file labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detection improvements Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants