简体   繁体   中英

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

I have an ASP.Net Core 5.0 web application that I need to detect mobile devices for. 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.

So far it looks like the best example I can find is at https://51degrees.com/developers/documentation/apis/netv32/tutorials/getting-started but it says "This tutorial assumes you are building this from within the 51Degrees Visual Studio solution." Like most people I already have a solution for my app which I need to use 51 Degrees with and cannot create a new 51Degrees Visual Studio solution. Plus, the example has way more code than I want to use. I want something that works like Request.Browser.IsMobileDevice without requiring more work.

Hi @WannabePuppetMaster,

51Degrees Device Detection solution can be used in similar manner as with AspNet MVC as described in this example .

The main difference is where the Device Data is obtained and made available to a 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.

You can find more details in this comment with examples.

You can find more examples (in various languages) and information from the documentation . For .NET specific details, please see Language Specific section.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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