Новейшие
Я загрузил мою демонстрацию , вам просто нужно заменить ClientId
, Tenant
и redirectUri
.
Что касается значения Tenant, вы можете использовать TenantID
или common
. Разница в том, что при использовании TenantID это приложение могут использовать только пользователи этого клиента. common может поддерживать других клиентов.
ОБНОВЛЕНИЕ
Если вы хотите развернуть приложение. Вам нужно изменить web.config
файл и Redirect URIs
на портале, как мои снимки экрана.


Test Pic:



PRIVIOUS
After reading your problem description, it is not clear why the problem occurred.
You can follow my steps to try again, I will show you step by step, your problem should be solved.
First add App Registrations
in the portal.
In the portal, add or modify Redirect URIs
, the default value is https://localhost:44368/
, and enable Access tokens
and ID tokens
.

- Измените
ClientId
значение web.config в проекте. ClientId копируется с портала.

- Установите точки останова в файлах HomeController.cs и Index.cs html, как показано на скриншоте ниже.

- F5 запустить проект, см. Скриншоты для следующих шагов, будет несколько примечаний.
Step1. Начать со страницы по умолчанию Home/Index
.

Step2. Click Sign in with Microsoft, it will jump into breakpoint in HomeController.cs
file. Because not sign in,so Request.IsAuthenticated
is false.

Step3. When you input your account and pwd, it will redirect to Home/Index
. Before that it will jump to breakpoint in Index.cshtml
file. You can see the value of Request.IsAuthenticated
after success login. It's true now.

Step4. Then you can see Index page.
введите описание изображения здесь