Method not found: "Newtonsoft.Json.JsonSerializerSettings Microsoft.AspNet.Mvc.MvcJsonOptions.get_SerializerSettings () '

Locally, my project works fine, but when I deploy to Azure using a web application, I get the following error on startup:

MissingMethodException: method not found: 'Newtonsoft.Json.JsonSerializerSettings Microsoft.AspNet.Mvc.Formatters.JsonOutputFormatter.get_SerializerSettings ()'. SmartAdmin.Startup. <> c.b__13_7 (MvcOptions options)

I tried this:

services.AddMvc(options => { options.Filters.Add(new UserPreferencesLoaderAtrribute()); var jsonFormatter = (JsonOutputFormatter)options.OutputFormatters.FirstOrDefault(f => f is JsonOutputFormatter); if (jsonFormatter != null) { jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); } }); 

And this:

 services.AddMvc(options => { options.Filters.Add(new UserPreferencesLoaderAtrribute()); }).AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); 
+6
source share
3 answers

Yes, I just worked all night and finally figured it out. Here is what you need to do:

Make sure you install: -Microsoft.AspNet.Mvc.Formatters.Json version "6.0.0-rc1-final" and also -Revert Netonsoft.Json - "6.0.6".

Then you can save this:

 services.AddMvc().AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); 

project.json:

"Microsoft.AspNet.Mvc.Formatters.Json": "6.0.0-rc1-final", "Newtonsoft.Json": "6.0.6"

I had a problem with the redistribution of problems, but in the end it worked.

Good luck

+6
source

Just received a call with Microsoft support as of yesterday (August 2, 2016). Azure App Services now only supports the ASP.NET kernel due to a violation:

The change is unlocked, and nothing but the ASP.NET kernel is supported, so the only option is to upgrade. The destructive change applies to all (regions), in the end all your instances will fail.

Is ASP.NET 5, Core RC1, RC2 supported in Azure App Service? NOT

https://blogs.msdn.microsoft.com/waws/2016/06/14/supporting-asp-net-5-core-rc1-on-azure-app-service/

Make sure your application has the latest ASP.NET kernel installed, not RC1 or RC2.

We were affected (Northern Europe) and updated our application with RC2, and it worked for the first time.

+1
source

We also saw this in production, contacted the team and got this: https://social.msdn.microsoft.com/Forums/en-US/f0a6bbaf-498a-4c1f-b869-6779ee18e04e/app-service-applications-may- experience-methodnotfound-exceptions-due-to-incorrect-newtonsoft-json? forum = windowsazurewebsitespreview

It seems that the fix for the App service is also on the way. Meanwhile, linked mail contains pretty much the same instructions as the other answers here.

0
source

All Articles