[英]I want to fetch ADFS server users using Auth0 API in Asp.net C# mvc. Is it possible to do so?
[英]Using Auth0 for Asp.Net MVC project how to redirect users directly to Signup page
我正在為 Asp.Net mvc 項目實施 Auth0。 我希望用戶在點擊注冊鏈接后直接進入注冊頁面。 我看到文檔說
通過在重定向到\/authorize<\/strong>時指定screen_hint=signup<\/strong>參數,您可以讓用戶直接登陸注冊頁面而不是登錄頁面。
這就是我在代碼中的內容,如何確保將其作為參數傳遞:
這解決了這個問題:
var authProperties = new AuthenticationProperties();
**authProperties.Dictionary.Add("screen_hint", "signup");**
authProperties.RedirectUri = Url.Action("Login", "Account");
HttpContext.GetOwinContext().Authentication.Challenge(authProperties, "Auth0");
現在在啟動時,我們需要獲取提供的參數:
RedirectToIdentityProvider = notification =>
{
if (notification.ProtocolMessage.RequestType == OpenIdConnectRequestType.Authentication)
{
// The context's ProtocolMessage can be used to pass along additional query parameters
// to Auth0's /authorize endpoint.
var paramsDictionary = notification.OwinContext.Request.Context.Authentication
.AuthenticationResponseChallenge?.Properties.Dictionary;
**if (paramsDictionary != null && paramsDictionary.ContainsKey("screen_hint"))
{
notification.ProtocolMessage.SetParameter("screen_hint",
paramsDictionary["screen_hint"]);
}**
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.