Web Forms
51Degrees ASP.NET Detector in Web Forms can both redirect to another page and change the content. To redirect, see the redirect section of the configuration .
The simplest way to change content on a Web Forms page is to use Page_Load event together with 51Degrees properties from the Request.Browser object:
Design Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs"
Inherits="FiftyOneDegreesExample.Test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label runat="server" ID="test_label"></asp:Label>
</div>
</form>
</body>
</html>
Code Behind:
using System;
namespace FiftyOneDegreesExample
{
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Browser["IsMobile"] == "True")
test_label.Text = "This is a mobile device";
else
test_label.Text = "This is not a mobile device";
}
}
}
This code will display 'This is a mobile device' if the request was from a mobile device and display 'This is not a mobile device' if it wasn't. This method can be used to invoke almost any action, such as using a different style sheet or sending different images. can also be used to redirect the request to another page.