Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make an webapi app in C# that connects to stripe. My app is using .NET framework 4.7.2.

Stripe documentation does say it's supporting .NET Framework 4.7.2 but I have trouble implementing the webhook.

The error I'm stuck at is this :

Error	CS1061	'IMvcBuilder' does not contain a definition for 'AddNewtonsoftJson' and no accessible extension method 'AddNewtonsoftJson' accepting a first argument of type 'IMvcBuilder' could be found (are you missing a using directive or an assembly reference?)


And this is the code where I'm receive the error, written in Startup.cs (I don't know if here is the right place because I don't have a Main class) :
C#
public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc().AddNewtonsoftJson();
}


With what can I replace AddNewtonsoftJson() here ?

What I have tried:

I'm using stripe documentation from here : https://stripe.com/docs/webhooks/quickstart[^]

I tried to install the nuget package named Microsoft.AspNetCore.Mvc.NewtonJson but it didn't worked because I'm working with .net framework 4.7.2 and this package doesn't work with it.
Posted
Updated 22-Nov-22 11:20am
v2
Comments
Richard Deeming 22-Nov-22 10:41am    
The AddMvc and AddNewtonsoftJson extension methods are for ASP.NET Core, not .NET Framework. Although they support .NET Framework, it looks like they only provide documentation for ASP.NET Core.

1 solution

As Richard mentioned, the documentation is for DotNet only. I looked at their videos and they look like DotNet only too. A couple of thoughts:

1. Here is the github repo for their library: GitHub - stripe/stripe-dotnet: Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for stripe.com.[^] you can look at those helper methods to see what they are doing. DotNet uses DI, but you should be able to make your own implementation.

2. Raise a support ticket. I am certain that you are not the only one with this question and they should have a canned support solution that they can respond with.

3. Maybe it is time to move to DotNet - your website will perform better. Here is documentation on migrating: Port from .NET Framework to .NET 6 - .NET Core | Microsoft Learn[^]
 
Share this answer
 
v2
Comments
Gaby94 6-Dec-22 7:39am    
To solve this issue I made another console app and yes I will migrate my app to .net core 6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900