MVC에서
해당 링크에
를 예를 들어
display-modes
를 선언 할 것
당신은 당신이 내 /APP_Start/DisplayModeConfig.cs 예를 들어
처럼 거의 아무것도 테스트하여 당신이 좋아하는 모든 모드를 설정할 수 있음을 얻었다되면
public class DisplayModeConfig
{
public static void RegisterDisplayModes(DisplayModeProvider provider)
{
// INFO: Allows to name views/partials/masters like viewname.iphone.cshtml, and MVC will choose this automatically
// INFO: Lets remove the default "Mobile" mode, since it's pretty useless
var mobileDefault = DisplayModeProvider.Instance.Modes.First(m => m.DisplayModeId == "Mobile");
if (mobileDefault != null)
{
DisplayModeProvider.Instance.Modes.Remove(mobileDefault);
}
// INFO: Now add one that actually works
provider.Modes.Insert(0,
new DefaultDisplayMode("Mobile")
{
ContextCondition = (context => (!string.IsNullOrEmpty(context.GetOverriddenUserAgent()) && Regex.IsMatch(context.GetOverriddenUserAgent(), @"mobile|android|kindle|silk|midp", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)))
});
// INFO: Order from least to most important (since we insert at position 0)
provider.Modes.Insert(1,
new DefaultDisplayMode("Win8")
{
ContextCondition = (context => (!string.IsNullOrEmpty(context.GetOverriddenUserAgent()) && context.GetOverriddenUserAgent().IndexOf("Windows NT 6.2", StringComparison.OrdinalIgnoreCase) >= 0))
});
}
}
@ Request.Browser. * 같은 @ Request.Browser.IsMobileDevice, @ Request.Browser.Version, .. 잘 작동하지만, 그 도우미를 사용하기 전에 테스트 할 것입니다. .
Safari를 사용하면'Develop> User Agent> iPhone' 등으로 사용자 정의 사용자 에이전트 문자열을 지정할 수 있습니다. – Jasen