Create a WepAPI without Newtonsoft Json on .NET 4.7.2

ms2 0 Reputation points
2023-09-01T05:37:18.5533333+00:00

Hi,

When we create a WEPAPI2 template project using VS2015, Newtonsoft json reference is automatically added. Is there any way to remove it and use oth. json provider say system.text one.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,323 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
291 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Lan Huang-MSFT 25,156 Reputation points Microsoft Vendor
    2023-09-01T08:51:54.0966667+00:00

    Hi @mp2022ms2,

    My suggestion is that you don't need to remove it as there are other references that depend on the Newtonsoft json reference.

    Newtonsoft json references will not be used as long as Newtonsoft.Json related methods are not used(using Newtonsoft.Json;).

    If you insist on removing the Newtonsoft json reference, you can use the NuGet package manager to do so. But the dependent packages also need to be removed.

    Load a project in Solution Explorer, select Project > Manage NuGet Packages, and then select the Installed tab.

    Select the package to uninstall in the left pane (use the Search box to find it, if necessary), and then select Uninstall from the right pane.

    User's image

    Best regards,

    Lan Huang


    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

  2. Bruce (SqlWork.com) 54,621 Reputation points
    2023-09-01T16:33:58.96+00:00

    The webapi nuget package is built with newtonsoft references, so even if you replace the json serialization, you still need the newtonsoft package.

    if you don’t want newtonsoft, then don’t use the webapi template. Just create a mvc site and use plain controllers.

    0 comments No comments