मैं पहचान का उपयोग किये बिना प्रमाणित करने की कोशिश कर रहा हूं। मुझे कुछ संस्करण मिलते हैं जो अन्य संस्करणों में इसे कैसे करें, हालांकि एएसपी.नेट कोर 2 के लिए कुछ भी नहीं।पहचान के बिना कुकी मिडलवेयर एएसपी.नेट कोर v2
नीचे मैंने जो कुछ किया है, वह नीचे है। लेकिन जब यह एक अपवाद SignInAsync जाता InvalidOperationException: No authentication handler is configured to handle the scheme: MyCookieMiddlewareInstance
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddCookieAuthentication("MyCookieMiddlewareInstance", o =>
{
o.LoginPath = new PathString("/Account/Login/");
o.AccessDeniedPath = new PathString("/Account/Forbidden/");
});
services.AddAuthentication();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseAuthentication();
}
public async Task<IActionResult> Login()
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.Name, "joe nobody")
};
var identity = new ClaimsIdentity(claims, "MyCookieMiddlewareInstance");
var principal = new ClaimsPrincipal(identity);
//blows up on the following statement:
//InvalidOperationException: No authentication handler is configured to handle the scheme: MyCookieMiddlewareInstance
await HttpContext.Authentication.SignInAsync("MyCookieMiddlewareInstance", principal);
return View();
}
वहाँ asp.net कोर v1.x (https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie) के लिए एक Microsoft दस्तावेज है फेंक दिया जाता है लेकिन IApplicationBuilder.UseCookieAuthentication() वी 2 में मूल्यह्रास हुआ है और नहीं मिला है कोई भी समाधान।
मैं कोशिश से संबंधित कुछ भी 2.0 सेटअप नहीं हूँ, लेकिन मैं 'में मैं आपके प्रश्न में बहुत रूचि रखता हूं क्योंकि इससे मुझे प्रभावित होगा। यदि आप उनके कुछ यूनिट परीक्षणों को देखते हैं, तो आप कम से कम किस वस्तु को कॉल करना चाहते हैं, इसका विचार प्राप्त करने में सक्षम हो सकते हैं: https://github.com/aspnet/Identity/pull/1119/commits/2bdfdb3220b3aca7513455652617af5685d5293c –