2016-10-06 3 views
3

ユーザーを正常に登録し、認証を確認した後、上記のエラーが発生します。私はapp.UseMvcへの呼び出しの前にapp.UseIdentity();を呼び出す このスキームを処理する認証ハンドラが設定されていません。Identity.Application

services.AddIdentity<ApplicationUser, IdentityRole<int>>(
      config => { config.User.RequireUniqueEmail = true; 
       config.Cookies.ApplicationCookie.LoginPath = "/Account/Login"; 
       config.Cookies.ApplicationCookie.Events = new CookieAuthenticationEvents() 
       { 
        OnRedirectToLogin = async ctx => 
        { 
         if (ctx.Request.Path.StartsWithSegments("/api") && ctx.Response.StatusCode == 200) 
         { 
          ctx.Response.StatusCode = 401; 
         } 
         else 
         { 
          ctx.Response.Redirect(ctx.RedirectUri); 
         } 
         await Task.Yield(); 
        } 
       }; 
      }).AddEntityFrameworkStores<VisualJobsDbContext, int>() 
      .AddDefaultTokenProviders(); 

とスタートアップの私のコンフィグ方法で

:私は私が最初にこれをIServiceCollectionにサービスを割り当てる

await _signInManager.SignInAsync(applicationUser, isPersistent); 

を呼び出そうとするとエラーが発生します

私はあることを私の呼び出しを変更した場合:

var myVal = await _signInManager.PasswordSignInAsync(applicationUser, password, true, false); 

彼らは私ヴァルは、私は何らかのエラーが

答えて

0

を投げられません「失敗」になり、複数の質問に同じ答えを追加しないでください、この答えNo authentication handler is configured to authenticate for the scheme: Microsoft.AspNet.Identity.External

+0

のようにapp.UseIdentity();方法ConfigureStartup.csにを追加しようとしています。最良のものに答え、残りを重複としてフラグを立てる。 http://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplicate-answer-to-several-questionsを参照してください。 –

関連する問題