Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I need to sent xml string to my controller (ASP.NEt mVC 3)

method on controller is like this

 [HttpPost, ValidateInput(false)]
        public ActionResult SetTherapyTemp(string xmlModel)
        {
            var deserializer = new XmlSerializer(typeof (PersonViewModel));
            var rdr = new StringReader(xmlModel);
           ...
        }


javascript ajax call is

    $.ajax({
                url: url,
                type: "POST", 
                data:  xml,
                success: function (data) { alert("OK") }
    });<br></pre>

In methot SetTherapyTemp XMLModel is always null!
How to send xmlString to controller?

share|improve this question
    
how do you tie the deserializer in with your model? – Demodave Apr 23 '15 at 16:28
up vote 0 down vote accepted

You need to specify the name of your model in the data parameter of your AJAX request:

$.ajax({
    url: url,
    type: "POST", 
    data:  { xmlModel: xml },
    success: function (data) { alert("OK") }
});

xmlModel is the name of your action parameter and need to be set.

share|improve this answer
    
thanks. It help me. Now it is working.... – user1189216 May 11 '13 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.