I am trying out the sample code of the Microsoft identity platform to add authentication and authorization to web applications. The sample from the link (https://github.com/Azure-Samples/ms-identity-aspnet-webapp-openidconnect) is working well in IIS Express. When I try to host the same with a custom website in IIS, it is not working as expected. The steps which I have followed, and problems occurred are mentioned below.
HOSTING IN IIS EXPRESS
The index page of the sample code has Sign in with Microsoft button
When clicking Sign in with Microsoft, it prompts for the username and password.
After entering the credentials, the index page is updated with the logged-in username
HOSTING IN CUSTOM IIS WEBSITE
The same application is hosted in a custom website in IIS. Here also while clicking the Sign in with Microsoft, it prompts for username and password
After entering the username and password, it is being redirected to the index page.
But the issue occurring is that the username is not updated and again showing the Sign in with Microsoft as the ClaimsPrincipal class cannot get the username
I cannot understand why this is happening meanwhile the same app is working well in IIS Express. Please help me around this. Thank you.
With the help of Microsoft azure dev support I was able to find the root cause. We have to have slash(/) at the end of the redirect-uri value like the below one.
<add key="ida:RedirectUri" value="https://localhost/AppTest/" />
In azure portal for your AD, you should have the same redirect-uri value for the corresponding application.