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 hosting the same application on 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
In IIS Express, when clicking Sign in with Microsoft, it prompts for the username and password.

After entering the credentials, it is being redirected successfully to the index page which is configured in the Web.config file.

HOSTING IN CUSTOM IIS WEBSITE
Here also while clicking the Sign in with Microsoft, it prompts for username and password
After entering the username and password, it is not redirecting to the configured page (https://localhost/AppTest/) and instead, it is landing in the URL https://localhost/.
Also, the network log of the browser shows that the location header has the value as “/” in the response header of the redirect uri request.
It is used before the UseOpenIdConnectAuthentication as mentioned below.

While debugging with Visual Studio, it is observed that after authentication the UseOpenIdConnectAuthentication is making a new unknown redirect request instead of the redirect uri configured in the Web.config and the request and its response have the location path value as “/”.
I cannot understand how this new redirect request arises meanwhile the same app is working well in IIS Express. Please help me to resolve this issue. Thank you.







