2014-02-20 16 views
2

我創建了移動設備的佈局 - _Layout.Mobile.cshtml 有自己的腳本,他們的樣式,所有沒關係,在平板電腦上加載完整版本的網站(_Layout.cshtml)。移動_Layout.Mobile.cshtml和iPad

在手機上加載移動版(_Layout.Mobile.cshtml)

但臺iPad(雖然他指的是平板電腦)加載移動版

如何解決呢?

回答

6

據我所知,你需要告訴DisplayModeProvider,iPad應該得到默認的顯示模式(桌面視圖)。

這可以用下面的代碼來實現:

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode() 
      { 
       ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0) 
      }); 

的代碼相當的說明,可以插入一種模式,是與iPad在用戶代理是的上下文中的缺省值。

查看更多在這裏:http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features在你的Global.asax.cs

的「瀏覽器的具體意見」

這應該在Application_Start去()方法