I wants to pass whole JSON objects into controller in MVC so that i can access whole object. I am using following code ..
Script called in View
var Email = {
To: $("#txtTo").val(),
Text: $("#txtTest").val(),
Subject: $("#txtSubject").val()
};
$.ajax({
type: "POST",
url: ("Controller/SendEmail"),
data: JSON.stringify(Email ),
datatype: "json",
contentType: "application/json; charset=utf-8",
cache: false,
success: function(htmlResult) {
alert("Mail Send")
},
error: function(msg) { alert("Error Occurs."); }
});
but when i call this in controller :
public ActionResult SendEmail(Model model)
{
string to = model.To ;
}
it gives null. How to resolve this?