connecting to azure active directory from asp.net application

Anjali Agarwal 1,366 Reputation points
2021-10-24T03:10:28.957+00:00

I am trying to connect to azure active directory from asp.net application. Below are my values I am putting in the application:

<add key="ClientId" value="XXXXXXXXXX" />  
    <add key="Tenant" value="XXXXXXXXXXXXXXXXXXXX" />  
    <add key="Authority" value="https://login.microsoftonline.com/{0}/v2.0" />  
    <add key="redirectUri" value="https://localhost:5000/" />  

For my redirect URI, I have https://localhost:5000/. This is what I configured in my App registrations in the Azure portal. when I run my application, I get this error:

ldqxq.png

when I change the redirectUri to https://localhost:44368/ then I can see the Microsoft login and Microsoft accepts the userId too, but I get an error after inputting my password saying :

AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application:

any help will be highly appreciated. I am following this article by Microsoft to write the code:

https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-v2-aspnet-webapp#prerequisites

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,253 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,235 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,457 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,471 Reputation points
    2021-10-24T05:51:46.42+00:00

    Hi @Anjali Agarwal ,

    After you have changed the application, did you change also the App registration to the same redirect URI?
    It has to be exactly same URI (host and port) otherwise it won't work.

    Hope this helps!

    0 comments No comments

  2. KalyanChanumolu-MSFT 8,316 Reputation points
    2021-10-25T07:34:38.363+00:00

    @Anjali Agarwal If you are debugging locally from your machine on port 44368, please change the redirect uri to https://localhost:44368/signin-oidc on the Azure AD App registration page.

    0 comments No comments