TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
MD Islam
NA
10
818
pass multidimentional array from ajax to asp.net mvc
May 6 2018 7:20 AM
hello, I have tried to post json data from angularjs $http post to asp.net mvc controller here is json data example
var
postdata =
{
Email:
"
[email protected]
"
,
selectedanswer: {0: 3, 1: 2, 2: 0, 3: 3, 4: 1}
};
angular js code
$http({
url:
"/page/PostFileWithData"
,
headers: {
'Content-Type'
:
'application/json; charset=utf-8'
},
method:
"POST"
,
dataType:
"json"
,
traditional:
true
,
data: JSON.stringify(postdata)
}).success(
function
(data) {
console.log(data);
}).error(
function
(data) {
console.log(
'fail'
);
});
controller
public
JsonResult PostFileWithData(UserModel userdata)
{
UserModel udata =
new
UserModel
{
Email = userdata.Email
selectedanswer = userdata.selectedanswer
};
return
Json(udata, JsonRequestBehavior.AllowGet);
}
my Modal
public
class
UserModel
{
public
string
Email {
get
;
set
; }
public
string
selectedanswer {
get
;
set
; }
}
now problem is that I am getting email field ok in console.log but selectedanswer is null
like this
{Email: "
[email protected]
", selectedanswer: null}
can you please help me at this point?
Reply
Answers (
1
)
The data contract type “…” cannot be deserialized because th
license plate recognition in asp.net c# can i get the code?