0

I have a pretty straightforward ASP .NET Core web site that uses Azure AD + OpenID for user authentication. Inside Azure I've added "https://my-site/signin-oidc" as a Redirect URI and inside my app settings I've set my CallbackPath to "/signin-oidc".

The problem is after authentication the browser always redirects to the home page.

For example the user will enter the following url into their address bar:
https://my-site/#/foo

They'll then be redirected to the azure sign-in page which has a uri like so:
https://login.microsoftonline.com/.../oauth2/v2.0/authorize?client_id=...&redirect_uri=https%3A%2F%2Fmy-site%3A64199%2Fsignin-oidc&[...]&sso_reload=true#/foo=

(Note where the '#/foo' fragment is placed)

After authentication succeeds they end up at the home page (https://my-site/).

Is there anyway for me to preserve the original URI and redirect the user to it after auth succeeds?

DNg
  • 422
  • 2
  • 15
  • I think this [official document](https://learn.microsoft.com/en-us/azure/active-directory/develop/reply-url#use-a-state-parameter) can answer your question. – Tiny Wang Jan 24 '23 at 03:03
  • I also find [another solution](https://stackoverflow.com/a/45670664) here, which means you can redirect to a business center page, in which you can check if the user already signed in then write your own business to redirect the application to your target page. – Tiny Wang Jan 24 '23 at 04:57

1 Answers1

0

Try using the post_login_redirect_url query parameter for this.

If you want to automatically navigate the user to #/foo' after logging in, you can set your login redirect to ~/.../authorize?post_login_redirect_url=/#/foo.

Ceemah Four
  • 458
  • 4
  • 11