📜 ⬆️ ⬇️

WebMatrix: working with mobile clients definition package from 51Degrees.mobi

51Degrees.mobi company is developing a solution for web developers to organize a simplified work with mobile platforms. Using the company's product, you can easily and accurately identify a mobile client that requests a web page and process this request by returning the data as required for the client.

51Degrees.mobi recently announced support for the Umbraco CMS and the WebMatrix development platform for which automatic installation packages were released. Packages are available at the following addresses:You can easily use the package for working with Umbraco CMS as it is written in this article .

Let's see how this works on the example package for WebMatrix.
')

Package installation


Create or open a site in WebMatrix based on the “Start Site” template. In the “Site” section of WebMatrix, you will find the “Administration of ASP.NET Web Pages” item (Figure 1).

image
Fig. 1. Link to project administration in WebMatrix

Go to the administration page using this item. After entering the password and fulfilling the project setting requirements (you must rename the file in the project), you will be taken to the list of NuGet packages (Figure 2).

image
Fig. 2. List of packages available for installation in the project

The first package is the 51Degrees.mobi package we need. Over time, it will cease to be the first, but you can always find it through the search.

Click “Install” in front of the package and the package will be installed in your project automatically (Figure 3).

image
Fig. 3. Confirmation of successful installation of the package

After that, you can close the window and return to WebMatrix. Click the “Restart” button to restart your site (Figure 4).

image
Fig. 4. Restarting the site

After that, run the site for execution. You will see the standard view of an ASP.NET web project or your own site (Figure 5).

image
Fig. 5. Running application

Request from mobile client


Now we will try to simulate the access to the page through the mobile client. To do this, we use the rich capabilities of the Internet Explorer browser developer tools. Call the toolbar via the F12 hot key or from the “Developer Tools” menu.

image
Fig. 6. Internet Explorer Developer Tools

In the tool window, select “Service”, “Change user agent string”, “Special” and set the following parameters:

Clear name - Windows Phone 7

User Agent String - Mozilla / 4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident / 3.1; IEMobile / 7.0)

image
Fig. 7. Installing a Mobile User Agent in Internet Explorer

Click “Install”. After that, refresh the site page in the browser. Now the web application, which is expanded by the 51Degrees.mobi package, considers that we have logged in from a mobile device and automatically forms the default mobile view page (Figure 8).

image
Fig. 8. Mobile page generated automatically when requested from a mobile client

Conclusion


Thus, our site with the installation of the 51Degrees.mobi package automatically received request processing functionality from mobile clients with full support for customer information. After that, the developer simply add the appropriate processing and, depending on the type of client, return certain pages with different designs.

Source: https://habr.com/ru/post/117879/


All Articles