Cannot convert lambda expression to type "CookieAuthenticationOptions" because it is not a delegate type

I am using a 1.0.1version asp.net coreand I am using authentication in my form.

I use UseCookieAuthenticationand it gives an error

Cannot convert lambda expression to type 'CookieAuthenticationOptions' because it is not a delegate type

In Startup.csconfigure method.

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?}"
        );
    });
}
+1
source share
1 answer

You need to pass parameters, not lambda:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AutomaticAuthenticate = true,
    AutomaticChallenge = true,
    LoginPath = "/Home/Login"
});
+2
source

Source: https://habr.com/ru/post/1017312/


All Articles