2

我正在实现一个自定义FormsAuthenticationProvider,我得到一个中间件转换错误。

No conversion available between System.Func`2[System.Collections.Generic.IDictionary`2
[System.String,System.Object],System.Threading.Tasks.Task] and Microsoft.Owin.OwinMiddleware
Parameter name: signature

我的堆栈包括

  • 欧文
  • 武士刀
  • 南希

我的具体问题是关于在哪里寻找关于如何实现自定义的示例的任何建议FormsAuthenticationProvider?除非有人能发现我的问题。

我的实现看起来像:

启动.cs

app.UseFormsAuthentication(new FormsAuthenticationOptions
            {
                LoginPath = "/login",
                LogoutPath = "/logout",
                CookieHttpOnly = true,
                AuthenticationType = Constants.ChainLinkAuthType,
                CookieName = "chainlink.id",
                ExpireTimeSpan = TimeSpan.FromDays(30),
                Provider = kernel.Get<IFormsAuthenticationProvider>()
            });

如果我删除app.UseFormsAuthentication(...)应用程序运行没有错误。

全栈跟踪

[ArgumentException: No conversion available between System.Func`2[System.Collections.Generic.IDictionary`2[System.String,System.Object],System.Threading.Tasks.Task] and Microsoft.Owin.OwinMiddleware
Parameter name: signature]
   Owin.Builder.AppBuilder.Convert(Type signature, Object app) +328
   Owin.Builder.AppBuilder.BuildInternal(Type signature) +336
   Owin.Builder.AppBuilder.Build(Type returnType) +42
   Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action`1 startup) +650
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action`1 startup) +86
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build() +185
   System.Lazy`1.CreateValue() +416
   System.Lazy`1.LazyInitValue() +152
   System.Lazy`1.get_Value() +75
   Microsoft.Owin.Host.SystemWeb.OwinApplication.get_Instance() +35
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): No conversion available between     System.Func`2[System.Collections.Generic.IDictionary`2[System.String,System.Object],System.Threading.Tasks.Task] and Microsoft.Owin.OwinMiddleware
Parameter name: signature]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,  HttpContext context) +254

可执行源代码(只需 F5 即可立即收到错误消息)

https://github.com/cnwilkin/ChainLink/tree/spike

4

1 回答 1

4

您可以尝试将 Microsoft.Owin.Host.SystemWeb 包的版本也更新到最新的 RC 并尝试吗?您在 rc 中有所有其他 Owin* dll,但这是 1.0.0。可能导致问题。另外请使用 Microsoft.Owin.Security.Cookies 而不是 Microsoft.Owin.Security.Forms。Forms 包现在已重命名为 Cookies。

于 2013-07-12T03:43:57.257 回答