NancyFXの埋め込みビュー機能を利用しようとしていますが、それを実現できませんでした。私はその例を使用しました。しかし、それでも、ナンシーはResourceViewLocationProvider
私のビューを見つけるために使用していないようです。
私のbootstrapp構成、
protected override void ConfigureApplicationContainer(IKernel existingContainer)
{
base.ConfigureApplicationContainer(existingContainer);
var currentAssembly = GetType().Assembly;
ResourceViewLocationProvider.RootNamespaces.Add(currentAssembly, "Candidate.Nancy.SelfHosted.Views");
}
protected override NancyInternalConfiguration InternalConfiguration
{
get { return NancyInternalConfiguration.WithOverrides(x => x.ViewLocationProvider = typeof(ResourceViewLocationProvider)); }
}
私のモジュール、
public class AccountModule : NancyModule
{
private readonly IUserManagement _userManagement;
public AccountModule(IUserManagement userManagement) : base("/account")
{
_userManagement = userManagement;
Get["/login"] = p => View["Login.cshtml"];
}
}
Login.cshtmlは/Views/Account/Login.cshtmlの下に配置され、埋め込みリソースとしてマークされます。
アプリケーションを実行すると、HTTP 500を取得しました。私には、アセンブリリソースではなくファイルシステムでそれを見つけようとしているようです。
Nancy.RequestExecutionException:ああ、いや!---> Nancy.ViewEngines.ViewNotFoundException:ビュー'Login.cshtml'が見つかりません現在利用可能なビューエンジン拡張機能:sshtml、html、htm、cshtml、vbhtml検査された場所:Login.cshtml、views / Login.cshtml、views / account /Login.cshtml,account/Login.cshtml,views/Account/Login.cshtml,Account/Login.cshtmlルートパス:D:\ Development \ Projects \ candidate.net \ src \ Candidate.Nancy.Selfhosted \ bin \ Debug at Nancy.ViewEngines.DefaultViewFactory.GetRenderedView(String viewName、Object model、ViewLocationContext viewLocationContext)at System.Dynamic.UpdateDelegates.UpdateAndExecute4 [T0、T1、T2、T3、TRet](CallSiteサイト、T0 arg0、T1 arg1、T2 arg2、T3 arg3)at Nancy.ViewEngines.DefaultViewFactory.RenderView(String viewName、Object model、
at Nancy.NancyEngine.ResolveAndInvokeRoute(NancyContext context)at Nancy.NancyEngine.InvokeRequestLifeCycle(NancyContext context、IPipelinesパイプライン)---内部例外スタックトレースの終了---
at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context、ErrorPipelineパイプライン、例外ex )。
更新:この問題はナンシー0.12.1.0で解決されました。