Aspnetcore.docs: Object arrives empty in method

Created on 15 Jun 2018  路  8Comments  路  Source: dotnet/AspNetCore.Docs

In my case, the ajax request works correctly, it prints the values in the console, but when it arrives in the Create method, the object is empty. And then it registers the name as null.

Print 1

Print 2

Most helpful comment

@davidfowl and @scottaddie
Thanks for helping me!

All 8 comments

@jonasmarco Can you please provide a link to the doc you're looking at?

Can you show your entire controller and show how you are posting the form body?

Hi @davidfowl

My Controller

Here: https://hastebin.com/ihorivemep.cs

Sorry, I'm not sure if I'm correctly stating the second question. So I'm going to send an image of the form.

image

You have some JavaScript code that鈥檚 doing the post right? What does that look like?

I think I found the problem, it was the lack of encode, I just added these two lines of code in the ajax call.

dataType: "json", contentType: "application/json; charset=utf-8",

@davidfowl and @scottaddie
Thanks for helping me!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YeyoCoder picture YeyoCoder  路  3Comments

nenmyx picture nenmyx  路  3Comments

danroth27 picture danroth27  路  3Comments

StevenTCramer picture StevenTCramer  路  3Comments

Rick-Anderson picture Rick-Anderson  路  3Comments