1

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?

1
  • how do you tie the deserializer in with your model? Commented Apr 23, 2015 at 16:28

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.