2013-08-24 2 views
6

부분 뷰는 디버그 모드로 렌더링되지만 릴리즈 모드에서는 렌더링되지 않습니다.Nancy Razor 부분 뷰가 해제 모드에서 렌더링되지 않습니다.

스택 트레이스

[ArgumentNullException: Value cannot be null. 
Parameter name: key] 
    System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +5895838 
    Nancy.ViewEngines.DefaultViewCache.GetOrAdd(ViewLocationResult viewLocationResult, Func`2 valueFactory) +329 
    Nancy.ViewEngines.Razor.RazorViewEngine.GetOrCompileView(ViewLocationResult viewLocationResult, IRenderContext renderContext, Assembly referencingAssembly, Type passedModelType) +186 
    System.Dynamic.UpdateDelegates.UpdateAndExecute5(CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) +401 
    CallSite.Target(Closure , CallSite , RazorViewEngine , ViewLocationResult , IRenderContext , Assembly , Object) +575 
    Nancy.ViewEngines.Razor.RazorViewEngine.GetViewInstance(ViewLocationResult viewLocationResult, IRenderContext renderContext, Assembly referencingAssembly, Object model) +1128 
    System.Dynamic.UpdateDelegates.UpdateAndExecute5(CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) +401 
    CallSite.Target(Closure , CallSite , RazorViewEngine , ViewLocationResult , IRenderContext , Assembly , Object) +495 
    Nancy.ViewEngines.Razor.<>c__DisplayClass1f.<RenderView>b__1e(Stream stream) +470 
    Nancy.ViewEngines.Razor.HtmlHelpers`1.Partial(String viewName, Object modelForPartial) +1872 
    RazorOutput.RazorView.<Execute>b__3() +632 
    Nancy.ViewEngines.Razor.NancyRazorViewBase`1.ExecuteView(String body, IDictionary`2 sectionContents) +374 
    Nancy.ViewEngines.Razor.<>c__DisplayClass1f.<RenderView>b__1e(Stream stream) +775 
    Nancy.Hosting.Aspnet.NancyHandler.ProcessRequest(HttpContextBase context) +81 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165 

master.cshtml (중요한 부분 만)

@if (IsSectionDefined("sidebar")) { 
    <div id="two-col"> 
     @RenderBody() 
    </div> 
    <div id="sidebar"> 
     @RenderSection("sidebar") 
    </div> 
} else { 
    <div id="one-col"> 
     @RenderBody() 
    </div> 
} 

index.cshtml

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic> 
@{ Layout = "master.cshtml"; } 

// html for body, doesn't use model 

@section sidebar { 
    @Html.Partial("/sidebars/sidebar.cshtml", Model) 
} 

sidebar.cshtml (시료 부)

<ul> 
@foreach (var item in Model.Items) 
{ 
    <li>@Html.Raw(@item.DisplayText)</li> 
} 
</ul> 
,
+0

출시 모드와 관련이있는 것 같습니다. https://groups.google.com/forum/#!searchin/nancy-web-framework/razor/nancy-web-framework/T95zFkxeJjg/LkWguk-xwI8J – Leslie

답변

8

최근에이 문제가 있었지만 마스터 레이아웃 페이지에 연결되었습니다. 인덱스 페이지를 보면 내 페이지, 마스터 페이지의 경로 또는 부분적인 경로 등 두 가지 중 하나 일 수 있습니다. 부분 URL에서 선행 슬래시를 제거하거나 마스터 페이지가 공유 폴더에있는 경우 URL에 전체 경로를 추가하십시오 (슬래시 또는 ~/제외).

여기가 해결책을 찾은 곳입니다. https://groups.google.com/forum/#!topic/nancy-web-framework/zRLth_hl2r8

HTH

우리의 경우
+0

감사합니다. 너무 많이! 나는 그것을 시도했다고 생각했지만, 분명히 그렇지 않았다. 내 부분에 선행 슬래시를 제거하고 모두 잘되고 있습니다. :) – Leslie

+0

이것은 이상합니다. Azure 웹 사이트에 여러 출판물에서 잘 작동했습니다. 나는 레이아웃과 부분적인 .cshtml 파일에 상대 경로를 사용하고 있었다. 이를 제거하면 문제가 해결되었음을 확인했습니다. – Aaron

1

우리가 참조 된 뷰가 설정 실종되었다고 된 문제 :

빌드 작업 : 파일이 디버그 모드에서 내용

의미했다 파일 시스템에서 읽지 만 릴리스 모드에서 실행 중일 때는 릴리스 bin 폴더에 복사되지 않습니다.