簡體   English   中英

自定義南希引導程序沒有被調用

[英]Custom Nancy bootstrapper not being called

我正在構建一個基於Nancy的應用程序,該應用程序將NancyHost用作嵌入式Web服務器。

我還嘗試通過創建自定義引導程序(如其文檔此處所述)來提供一些靜態內容。 但是,我看到的問題是,此自定義引導程序類從未實例化,並且從未調用ConfigureConventions方法。 為了確保已注冊此自定義引導程序,我需要執行任何特定操作嗎?

以下是自定義引導程序代碼:

using Nancy;
using Nancy.Conventions;
using System;

namespace Application
{
    public class CustomBootstrapper : DefaultNancyBootstrapper
    {
        protected override void ConfigureConventions(NancyConventions conventions)
        {
            Console.WriteLine("test");
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("client", @"client"));
            conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("lib", @"lib"));
            base.ConfigureConventions(conventions);
        }
    }
}

事實證明,我必須將引用傳遞給NancyHost構造函數中的CustomBootstrapper。

var host = new NancyHost(new Uri(JsonHelper.URL), new CustomBootstrapper(), config);
host.Start();

您的引導程序是否在另一個程序集中?

請檢查文檔中的 IncludeInNancyAssemblyScanning

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM