2017-05-31 1 views
1

Ich verwende 1.0.1 Version von asp.net core und ich verwende Authentifizierung in meinem Formular.Kann Lambda-Ausdruck nicht in Typ "CookieAuthenticationOptions" konvertieren, da es kein Delegattyp ist

Ich benutze UseCookieAuthentication und seine gibt einen Fehler

Kann nicht Lambda-Ausdruck konvertieren ‚CookieAuthenticationOptions‘ zu geben, weil es kein Typ Delegierter ist

Im Startup.cs konfigurieren Methode.

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?}" 
     ); 
    }); 
} 
+0

Bitte erläutern Sie, was Sie tun wollen und was das Problem genauer ist –

Antwort

2

Sie müssen in den Optionen zu übergeben, keine Lambda:

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

nicht funktioniert, seine einen Fehler geben –

+0

Oops , habe vergessen, Semikolons in Kommas zu ändern: D – juunas

+0

jetzt funktioniert es Danke –

Verwandte Themen