【发布时间】:2012-06-07 22:38:02
【问题描述】:
我正在使用..
ASP.net MVC 451Degrees.mobijQuery Mobile
通过这些技术的帮助,我可以让我的 Web 应用程序的 UI 设计不仅在基于桌面的浏览器上看起来很好,而且在基于移动的浏览器上也很好看,而无需我单独创建项目。
但是当涉及到更具体的移动设备时,我想调用特定的视图文件。
所以我在Global.asax 文件中使用下面的代码。
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
//The Android view
DisplayModes.Modes.Insert(0, new DefaultDisplayMode("android")
{
ContextCondition = Context => Context.Request.Browser.Platform == "Android"
});
//The iPhone view
DisplayModes.Modes.Insert(0, new DefaultDisplayMode("iphone")
{
ContextCondition = Context => Context.Request.Browser.MobileDeviceModel == "iPhone"
});
//The mobile view
//This has a lower priority than the other two so will only be used by a mobile device
//that isn't Android or iPhone
DisplayModes.Modes.Insert(1, new DefaultDisplayMode("mobile")
{
ContextCondition = Context => Context.Request.Browser.IsMobileDevice
});
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
不幸的是,Android and IPhone specific view 在我从 iPhone Emulator 和 Opera Mobile Emulator 调用页面时不会加载。
_Layout.cshtml [loaded from desktop based browser]
_Layout.Android.cshtml [never loaded]
_Layout.iPhone.cshtml [never loaded]
_Layout.Mobile.cshtml [loaded from mobile based any browser including iphone, opera]
我认为有问题的是,当我使用 NuGet 包从 51Degrees.mobi 下载时,我只得到了两个文件。
FiftyOne.Foundation.dll51Degrees.mobi.config
尽管我认为我应该得到App_Data/Devices.dat,但我仍然只能从 51Degrees.mobi 得到这两个文件。
谁能给我建议,我可以如何调用 iPhone 和 Android 的特定视图? 我们将不胜感激每一个建议。
【问题讨论】:
-
我的教程 ASP.NET MVC 4 Mobile Features (asp.net/mvc/tutorials/aspnet-mvc-4-mobile-features) 适用于 iPhone。
-
谢谢@Rick.Anderson-at-Microsoft.com
标签: c# asp.net-mvc jquery-mobile 51degrees