无法将 lambda 表达式转换为类型 'CookieAuthenticationOptions',因为它不是委托类型
Cannot convert lambda expression to type 'CookieAuthenticationOptions' because it is not a delegate type
我正在使用 asp.net core
的 1.0.1
版本,并且在我的表单中使用身份验证。
我使用 UseCookieAuthentication
,它给出了一个错误
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:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
LoginPath = "/Home/Login"
});
我正在使用 asp.net core
的 1.0.1
版本,并且在我的表单中使用身份验证。
我使用 UseCookieAuthentication
,它给出了一个错误
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:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
LoginPath = "/Home/Login"
});