DELETE method return 401 error

jpnddsk 46 Reputation points
2022-09-21T20:25:33.633+00:00

Hi all,

I have a .net core mvc application published on iis and when i use delete request i get 401 Unauthorized Error.

Can someone help me fix it?

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,137 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sam Wu-MSFT 7,036 Reputation points Microsoft Vendor
    2022-09-22T03:03:18.873+00:00

    @jpnddsk

    I found a case with the same problem as yours on stackoverflow, you can try this solution:

    Enable delete verb on the iis server -> .NET Authorization Rules.

    243710-1.png


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Michael Taylor 47,711 Reputation points
    2022-09-21T21:16:32.11+00:00

    Not sure what you want us to help you with here. 401 means you are attempting to do something you don't have permission to do. Since you wrote the code you should verify that the code that calls this API is passing whatever user credentials your app uses. You should then look at the corresponding action on the server side and ensure you're getting the credentials. If this is the only place you are having this issue but you require authentication for all other endpoints then the problem is with the calling code. If none of your endpoints work then it would be a deployment issue I'd wager.

    If you want us to help you further you're going to need to provide us some code such as how you're delete action is defined, the auth setup, the client code calling the API and any pertinent information about how your app and IIS are configured for authentication.

    0 comments No comments