本文介绍了无法将lambda表达式转换为"CookieAuthenticationOptions"类型,因为它不是委托类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用asp core的1.0.1版本,并且正在使用表单中的身份验证.
I'm using 1.0.1 version of asp core and I'm using authentication in my form.
我使用UseCookieAuthentication并给出了错误
无法将lambda表达式转换为类型"CookieAuthenticationOptions",因为 它不是委托类型
Cannot convert lambda expression to type 'CookieAuthenticationOptions' because it is not a delegate type
在Startup.cs中,配置方法.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseApplicationInsightsRequestTelemetry(); app.UseExceptionHandler("/Home/Error"); app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseSession(); app.UseCookieAuthentication(options => { options.AutomaticAuthenticate = true; options.AutomaticChallenge = true; options.LoginPath = "/Home/Login"; }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=About}/{id?}" ); }); }推荐答案
您需要传递选项,而不是lambda:
You need to pass in the options, not a lambda:
app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, AutomaticChallenge = true, LoginPath = "/Home/Login" });更多推荐
无法将lambda表达式转换为"CookieAuthenticationOptions"类型,因为它不是委托类型
发布评论