2017-08-28 133 views
-1

如何在使用ADB2C登錄/註冊後重定向到自定義頁面?在ADB2C登錄/註冊後重定向到自定義頁面 - MVC

我想填充我的模型,並把它傳遞給登入/註冊後的新看法,但它一直重定向到以下幾點:https://localhost:44342/account/signupsignin

下面是我的代碼:

[AllowAnonymous] 
     public void SignUpSignIn() 
     { 
      // Use the default policy to process the sign up/sign in flow 
      if (!Request.IsAuthenticated) 
      { 
       try 
       { 
        HttpContext.GetOwinContext().Authentication.Challenge(); 
        return; 
       } 
       catch (Exception ex) 
       { 

       } 

      } 

      string email = ((ClaimsIdentity)User.Identity).FindFirst("emails").Value; 

      // We do not want to use any existing identity information 
      EnsureLoggedOut(); 

      AccountRegistrationModel ARVM = new AccountRegistrationModel(); 

      ARVM = CallPersonalDetails(_registrationRepository.GetUserId(email), "English"); 

      RedirectToAction("Account", "Register_PersonalDetails", ARVM); 

      //HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/account/Register_PersonalDetails" }, OpenIdConnectAuthenticationDefaults.AuthenticationType); 



      //Response.Redirect("/"); 
     } 

我已經使用註釋掉以及部分多數民衆贊成嘗試:

//HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/account/Register_PersonalDetails" }, OpenIdConnectAuthenticationDefaults.AuthenticationType); 

這個「顯示」正確的URL,但顯示一個頁面,說其沒有找到。我需要通過模型以及 - 我如何

  1. 重定向到我自己的自定義頁面的登入/註冊
  2. 後傳遞一個模型來此頁爲好。

感謝您的任何幫助提前。

回答

1

所以我才弄明白了。

Response.Redirect(「/」)重定向到我的Home Controller中的Index ActionResult,因此在該ActionResult中,我使用RedirectToAction將我指向我想要的View(顯然,有代碼正在執行所需的檢查等。首先)

也許這不是正確的做法,但它爲我工作。

謝謝。

相關問題