我正在努力实现自定义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
的示例的任何建议?除非有人能发现我的问题。
我的实现如下:
Startup.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,您就会立即收到错误)
答案 0 :(得分:4)
您是否可以尝试将Microsoft.Owin.Host.SystemWeb软件包的版本更新到最新的RC并尝试?你在rc中拥有所有其他Owin * dll但是这是1.0.0。可能导致问题。另请使用Microsoft.Owin.Security.Cookies而不是Microsoft.Owin.Security.Forms。 Forms包现已重命名为Cookies。