0

我已经设置了一个运行从 github 和 nginx 构建的 mono 3.2.1 的生产服务器。一切正常,常规子域和我的monoserved mvc4 站点。我还切换到 unix 套接字而不是 tcp,因为我注意到在 ram 使用方面有一些奇怪的行为。

到目前为止 - 我只使用了我在具有相同配置的 windows VPS 上使用的系统资源的 10%,所以 linux 托管的 mvc 就像第一次发现切片面包:D

但是,尝试以下操作时出现 NotImplementedException 错误:

在我的 Global.asax.cs 文件中,在 Application_Start() 下的捆绑设置之后,我正在注册或至少尝试注册检查它是否是移动设备,从而为我的 Index.Mobile.cshtml 服务

像这样

protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

        DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iphone")
        {
            ContextCondition = Context =>
                            Context.Request.Browser["HardwareModel"] == "iPhone"
        });

        DisplayModeProvider.Instance.Modes.Insert(1, new DefaultDisplayMode("android")
        {
            ContextCondition = Context =>
                            Context.Request.Browser["PlatformName"] == "Android"
        });

        DisplayModeProvider.Instance.Modes.Insert(2, new DefaultDisplayMode("mobile")
        {
            ContextCondition = Context =>
                            Context.Request.Browser["IsMobile"] == "True"
        });

    }

据我发现,在单声道的aspnetwebstack中,有DisplayModeProvider(即)

https://github.com/mono/aspnetwebstack/blob/master/src/System.Web.WebPages/DisplayModeProvider.cs

但是,如果我的 Global.asax.cs 中有这些行,我会在尝试加载页面时收到错误消息(在我的 webconfig 中)

谁能指出我正确的方向,因为我需要这个网站为手机提供不同的页面:)

非常感谢

戴夫

4

1 回答 1

1

现在一切都很好。

我已经更改了将它们添加到 DisplayModeProvider 的方式。

如果我按以下方式进行操作,则效果很好:

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile")
                                                  {
            ContextCondition = (ctx =>
                                ctx.Request.UserAgent.IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0 ||
                                ctx.Request.UserAgent.IndexOf("iPhone", StringComparison.OrdinalIgnoreCase) >= 0 ||
                                ctx.Request.UserAgent.IndexOf("Windows Phone", StringComparison.OrdinalIgnoreCase) >= 0 ||
                                ctx.Request.UserAgent.Contains("Mobile Safari")||
                                ctx.Request.UserAgent.Contains("Android") &&
                                ctx.Request.UserAgent.IndexOf("Mobile", StringComparison.OrdinalIgnoreCase) <= 0
                                )
        });
于 2013-10-27T13:04:09.810 回答