无法将lambda表达式转换为

无法将lambda表达式转换为

本文介绍了无法将lambda表达式转换为"CookieAuthenticationOptions"类型,因为它不是委托类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net core1.0.1版本,并且正在使用表单中的身份验证.

I'm using 1.0.1 version of asp.net core and I'm using authentication in my form.

我使用UseCookieAuthentication并给出了错误

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"类型,因为它不是委托类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-21 00:29