2015-03-31 139 views
3

我試圖創造使用令牌身份驗證owin web應用程序託管網絡應用程序,我的啓動不具有Owin使用令牌認證

任何特殊設置類似的例子https://github.com/NancyFx/Nancy/wiki/Token-Authentication

public class Bootstrapper : DefaultNancyBootstrapper 
{ 
    protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) 
    { 
     TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve<ITokenizer>())); 
    } 
} 

礦簡直是

public void Configuration(IAppBuilder app) 
{ 
    app.UseNancy(); 
} 

我已經定義像

模塊

沒有多少隻是我知道,但是當我得到令牌化時,我得到了一個類型爲Nancy.ErrorHandling.RouteExecutionEarlyExitException的異常,它確實沒有在消息或堆棧跟蹤中指示問題的任何內容。

我目前收容了HTTP在卡西尼上的.NET 4.5.1

任何指針將不勝感激

更新:

消息是:

Exception of type 'Nancy.ErrorHandling.RouteExecutionEarlyExitException' was thrown. 

Stack trace is: 
    at Nancy.Authentication.Token.Tokenizer.Tokenize(IUserIdentity userIdentity, NancyContext context) 
    at Samaritan.Hosting.HttpServices.HomeModule.<>c__DisplayClass11.<.ctor>b__7(Object _) in c:\src\DukeSoftware\Samaritan\Main\Samaritan.Hosting.HttpServices\HomeModule.cs:line 39 
    at CallSite.Target(Closure , CallSite , Func`2 , Object) 
    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 
    at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context) 

我嘗試設置像這樣的startup.cs

public class Startup 
{ 
    public void Configuration(IAppBuilder app) 
    { 
     app.UseNancy(); 
    } 
} 

public class Bootstrapper : DefaultNancyBootstrapper 
{ 
    protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) 
    { 
     TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve<ITokenizer>())); 
    } 
} 

,但我得到了以下異常

{"Located multiple bootstrappers:\r\n - Samaritan.Hosting.HttpServices.BootStarapper\r\n - Samaritan.Hosting.HttpServices.Bootstrapper\r\n\r\nEither remove unused bootstrapper types or specify which type to use."} 

所以我刪除了bootsrapper和剛剛離開的啓動。當你聲明構造函數爲public HomeModule(ITokenizer tokenizer) 所以我沒有想到創建tokenizer是一個問題

+1

你能發佈異常消息和堆棧跟蹤嗎? – 2015-03-31 12:03:45

+1

另請參見:您的應用程序中是否有引導程序? – 2015-03-31 12:04:23

回答

1

你發現修復嗎?

我遇到了同樣的異常。這是因爲我有'DefaultNancyBootstrapper'類的孩子在同一目錄中的2個EXE文件。

我得使用舊南希v1.0。所以看起來除了在一個地方使用'DefaultNancyBootstrapper'以外別無他法。