使用51degrees重定向到移动子域

时间:2011-09-14 15:37:19

标签: c# mobile 51degrees

我正在使用51degrees API进行移动重定向:http://51degrees.codeplex.com/

当使用51degrees检测到移动设备时,我可以使用51degrees配置从任何桌面页面重定向到移动主页。即http://www.mydomain.com/somepagehttp://m.somepage.com/default

我无法做的是重定向到同一页面,即从http://www.mydomain.com/somepagehttp://m.somepage.com/somepaage

是否可以重定向到同一页面?

2 个答案:

答案 0 :(得分:5)

选项1 :仅对移动侦测部分使用51度,并自行连接重定向。从web.config中删除<redirect>元素,并在Global.asax文件中尝试以下内容:

void Application_BeginRequest(object sender, EventArgs e)
{
    if (HttpContext.Current.Request.Browser.IsMobileDevice)
    {
        Response.Redirect("http://m.mydomain.com" + Request.RawUrl);
    }
}

选项2 :在web.config文件的<redirect>元素中,添加属性originalUrlAsQueryString=true。这会将名为 origUrl 的查询字符串发送到移动主页,为您提供重定向到所请求页面的移动版本的选项。

答案 1 :(得分:0)

您可以在51Degrees.mobi User Guide的2.1.2节中找到有关如何将其配置为重定向到网页的移动版本的信息。