Webapp создает / редактирует / удаляет функции, не работающие после включения Azure аутентификации Active Directory - PullRequest
0 голосов
/ 02 апреля 2020

Я включил Azure Вход в активную директорию для моего веб-приложения CRUD. NET MVC C#.

на основе https://docs.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad

Я мог войти в свое приложение, увидеть содержимое на страницах, но некоторые грубые операции, такие как создание, редактирование, удаление, не работают, когда я нажимаю на эти кнопки, я получаю сообщение об ошибке "An произошла ошибка при обработке вашего запроса. " На localhost все работает гладко.

Скорее всего, у методов с [HttpPost] возникают проблемы, добавить ли какой-нибудь код для решения этой проблемы? любая подсказка будет полезна, плохо знакома с AAD

Редактировать: На основании комментария от @Jalpa Panchal я вытащил журнал:

>   A claim of type
> 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'
> or
> 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider'
> was not present on the provided ClaimsIdentity. To enable anti-forgery
> token support with claims-based authentication, please verify that the
> configured claims provider is providing both of these claims on the
> ClaimsIdentity instances it generates. If the configured claims
> provider instead uses a different claim type as a unique identifier,
> it can be configured by setting the static property
> AntiForgeryConfig.UniqueClaimTypeIdentifier.  Description: An
> unhandled exception occurred during the execution of the current web
> request. Please review the stack trace for more information about the
> error and where it originated in the code. 
> 
> Exception Details: System.InvalidOperationException: A claim of type
> 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'
> or
> 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider'
> was not present on the provided ClaimsIdentity. To enable anti-forgery
> token support with claims-based authentication, please verify that the
> configured claims provider is providing both of these claims on the
> ClaimsIdentity instances it generates. If the configured claims
> provider instead uses a different claim type as a unique identifier,
> it can be configured by setting the static property
> AntiForgeryConfig.UniqueClaimTypeIdentifier.
> 
> Source Error: 
> 
> 
> Line 12: @using (Html.BeginForm()) 
  Line 13: { Line 14:    
> @Html.AntiForgeryToken() Line 15:  Line 16:

Мой метод удаления код:

    [HttpPost, ActionName("Delete")]
    [ValidateAntiForgeryToken]
   public ActionResult DeleteConfirmed(string id)
    {
        Trace.WriteLine("POST /Todos/Delete/" + id);
        user usr = db.users.Find(id);
        db.users.Remove(usr);
        db.SaveChanges();
        return RedirectToAction("Index");
    }

Удаление токенов Anti-Forger позволяет загружать страницы, мне нужно добавить их с другим кодом

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...