HttpClient in ASP.NET MVC C# is not working on deployment windows server 2016

Kishan Verma 6 Reputation points
2021-10-12T16:44:58.843+00:00

HttpClient in ASP.NET MVC C# is not working on deployment windows server 2016 (returns 500 status code) but it perfectly works in local server.
Kindly, may I know, is there something missing to declare before calling APIs with HttpClient? Thank you.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,572 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,581 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,221 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,786 Reputation points
    2021-10-13T08:49:11.707+00:00

    Hi there,

    Web API apps typically use several HTTP verbs: GET, POST, PUT, DELETE, and sometimes PATCH. That being said, developers may run into situations where those verbs are implemented by another IIS module on their production IIS server, which leads to a situation where a Web API controller that works correctly in Visual Studio or on a development server will return an HTTP 405 error when it is deployed to a production IIS server.

    You can Troubleshoot Web API2 apps that work in Visual Studio and fail on a production IIS server from here https://learn.microsoft.com/en-us/aspnet/web-api/overview/testing-and-debugging/troubleshooting-http-405-errors-after-publishing-web-api-applications

    ---------------------------------------------------------------------------------------------------------------------------------

    If the reply is helpful, please Upvote and Accept it as an answer

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.