Hello, I have asp.net web forms project with Azure AD authentication, now in this project i have two forms "webfrom1.aspx" and "webform2.aspx" now i need that, if user "it" is login then redirect to "web form 1.aspx" or if user "finance" login then redirect to "web form 2.aspx". please help me! Thanks
2 Answers
Answers 1
As part of your authentication configuration, you could specify a RedirectUri to a page that could make the decision on where to redirect (webform1.aspx or webform2.aspx) based on the user.
Answers 2
if user "it" is login then redirect to "web form 1.aspx" or if user "finance" login then redirect to "web form 2.aspx".
You cannot redirect to different URLs from Azure AD based on user's information. Instead, you will have place the logic at landing page of your application such as Home page URL.
Then you direct user to desired page based on your business logic. For example,
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (User != null && User.Identity.IsAuthenticated) { switch (User.Identity.Name.ToLower()) { case "it": Response.Redirect("~/WebForm1.aspx"); break; case "finance": Response.Redirect("~/WebForm2.aspx"); break; } } } }
Please feel free to take a look at my working sample code written in ASP.NET Core using Visual Studio 2017 at GitHub.
0 comments:
Post a Comment