在 Blazor 服务器端应用程序中处理不同浏览器功能的最佳方式是什么?

What is the best way to handle different browser features within a Blazor Server-Side Application?

编辑:我最初只想知道如何在 Blazor 服务器端检测不同的浏览器并相应地更改我的应用程序的行为。可以在这里找到答案: 然后我从@CodeCaster 那里了解了特征检测并更改了这个问题,因为这似乎是解决我的问题的更好方法。

这是我的首字母 post:

我想根据客户端使用的浏览器支持的内容,在起始页加载不同的内容。 (或者让客户端根据其浏览器加载某个起始页面)像这样:Browser Detection

检测客户端正在使用的浏览器的最佳方法是什么?Blazor 服务器端应用程序中的最佳位置在哪里?

What is the best way to detect the browser

你不需要,过去几十年的做法需要取消。请改用特征检测。

参见:

要点(摘自上次link):

The problem with this approach is twofold. First, it bundles multiple assumptions about the features the browser supports in one check. A single wrong assumption can break the site. So as a developer you have to keep track of exactly which features each version of a specific browser supports.

The second issue is that this browser check doesn’t take browser versions into consideration and therefore isn’t future-proof. Even if it works with today’s version of a browser, the next release might not require—or worse, might remove support altogether for—a workaround that the browser detection was used to add to the site.