繁体   English   中英

如何通过 Razor 页面使用 51 度移动设备检测?

[英]How Do I Use 51 Degrees Mobile Device Detection with a Razor Page?

我有一个需要检测移动设备的 ASP.Net Core 5.0 web 应用程序。 I downloaded the 51 Degrees NuGet Package using the Visual Studio Nuget Package Manager, but I cannot figure out how to use it from a Razor Page and cannot find any examples of it being used with Razor Pages anywhere.

到目前为止,看起来我能找到的最好的例子是https://51degrees.com/developers/documentation/apis/netv32/tutorials/getting-started但它说“本教程假设您是从 51Degrees Visual工作室解决方案。” 像大多数人一样,我已经为我的应用程序提供了一个解决方案,我需要使用 51 度,并且无法创建新的 51 度 Visual Studio 解决方案。 另外,该示例的代码比我想要使用的要多得多。 我想要像 Request.Browser.IsMobileDevice 这样的东西,而不需要更多的工作。

嗨@WannabePuppetMaster,

51Degrees 设备检测解决方案可以以与本示例中描述的 AspNet MVC 类似的方式使用。

主要区别在于获取Device Data并将其提供给Page的位置。 In MVC, the data is obtained in the Controller before passing to the View , while in Razor Page it will need to be obtained in the Page Model so that the Page can access it via the Model object.

您可以通过示例在此评论中找到更多详细信息。

您可以从文档中找到更多示例(各种语言)和信息。 对于 .NET 的具体细节,请参阅Language Specific部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM