禁用 aspnet.friendlyurl 的平板电脑移动重定向



我的网站使用Twitter Bootstrap进行响应,桌面页面是为平板电脑和台式机设计的。aspnet.friendlyUrls将平板电脑设备视为移动设备,并将其发送到".mobile.aspx"对等设备。如何禁用此行为并将平板电脑保留在桌面页面上?

两周后,仍然没有插入,甚至没有评论?我是唯一一个真正使用aspnet的人吗。FriendlyUrls,即使它在新的VS2013 Asp中发布。默认情况下净项目?

没有关闭此功能的设置,但您可以通过删除网站来禁用此功能。可移动的Master和ViewSwitcher文件

不再需要以下文件:

现场。可移动的母版
-现场。可移动的Master.cs
-现场。可移动的Master.designer.cs

ViewSwitcher
-ViewSwitcher.cs
-ViewSwitcher.ascx.cs

感谢@fortboise简化了我的回答

删除不会解决问题,方法是覆盖TrySetMobileMasterPage。

第一步:创建一个类

public class MyWebFormsFriendlyUrlResolver : Microsoft.AspNet.FriendlyUrls.Resolvers.WebFormsFriendlyUrlResolver
{
protected override bool TrySetMobileMasterPage(HttpContextBase httpContext, Page page, String mobileSuffix)
{
    if (mobileSuffix == "Mobile")
    {
        return false;
    }
    else
    {
        return base.TrySetMobileMasterPage(httpContext, page, mobileSuffix);
    }
}

}

进入App_Start/RouteConfig并设置后:

public static void RegisterRoutes(RouteCollection routes)
    {
        var settings = new FriendlyUrlSettings();
        settings.AutoRedirectMode = RedirectMode.Permanent;
        routes.EnableFriendlyUrls(settings, new MyWebFormsFriendlyUrlResolver());
    } 

最新更新