2013-05-24 3 views
2

가 만든 초기화 모듈EPiServer 7 MVC IDisplayModes

[InitializableModule] 
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))] 
public class DisplayModesInitialization : IInitializableModule 
{ 
    public void Initialize(InitializationEngine context) 
    { 
     if (context.HostType == HostType.WebApplication) 
     { 
      System.Web.WebPages.DisplayModeProvider.Instance.Modes.RemoveAt(0); 
      context.Locate.DisplayChannelService() 
           .RegisterDisplayMode(new DefaultDisplayMode(RenderingTags.Mobile) 
           { 
            ContextCondition = (r) => r.Request.Browser.IsMobileDevice 
           });     
     } 
    } 

    public void Preload(string[] parameters) { } 

    public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context) { } 
} 

를 링크

http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/7/Content/Display-Channels/

을 따르고 당신이 볼 수 있듯이, 기존의 "모바일"디스플레이 모드를 EPiServer Displ을 통해 생성 된 디스플레이 모드로 대체하려고 시도했습니다. ayChannelService(). 그냥 홈페이지에 검색

이 작품을 좋아하지만 모바일 브라우저로 사용자 에이전트를 강제로 할 때, 즉

이 나타나는 그러나 Index.mobile.cshtml 여전히 _Layout.cshtml 대신 _Layout.mobile.cshtml의 찾고 될 ... 정확한보기를 누르 않습니다 심지어 그것을 발견하지 못한다.

The file "~/Views/Shared/_Layout.cshtml" could not be rendered, because it does not exist or is not a valid page. 

누구나 성공적으로 EPiServer DisplayChannelService을 통해 MVC에 대한 모바일 IDisplayMode을 만들? 내가 명시 적으로 모바일보기

@{ 
    Layout = "~/Views/Shared/_Layout.mobile.cshtml"; 
} 

의 레이아웃을 설정하는 경우

또한 또한을 찾기 위해 실패하면?

The file "~/Views/Shared/_Layout.mobile.cshtml" could not be rendered, because it does not exist or is not a valid page. 

_Layout 및 _Layout.mobile 모두 해당 위치에 존재합니까?

답변

1

관리가 제대로 작동합니다.

@{ 
    Layout = "~/Views/Shared/_Layout.cshtml"; 
    DisplayModeProvider.Instance.RequireConsistentDisplayMode = true; 
} 

그래서 나는 DisplayModeProvider.Instance.RequireConsistentDisplayMode = true;을 제거하고 지금은 작동합니다

는 _ViewStart.cshtml는 다음과 같은 설정을 한 것으로 발견했다.

홈페이지 및 모바일 및 데스크톱 레이아웃에 대한 모바일보기와 데스크톱보기가 모두있는이 문제의 원인이 확실하지 않은 이유는 무엇입니까?

관련 문제