how to get data in mvc using http post

say, I have controller method and a corresponding view (see below).

once I load the view, I have a self invoking JavaScript function, that calls the same controller method.
code below, shows the get request, when I test this, I get the value of 1 in the id parameter of my ProcessData method.
in Get request, the data is passed in the query string, which is mapped to my parameter name by ASP.NET ( I guess by the process of model binding). I understand this part.

My question is, if i wanted to do a post request and send a XML data over to the same controller method, how can I achieve this.

In a post request, how do we read data in the controller?

controller -
public ActionResult ProcessData(string id) {          
      return View();

view -

    ViewBag.Title = "test";


@section scripts {
    <script type="text/javascript">
        (function () {
                type: "Get",
                url: '@Url.Action( "ProcessData", "Test")',
                contentType: "application/xml; charset=utf-8",
                data: {id : 1},              
                success: successFunc,
                error: errorFunc
            function successFunc(data, status) {
            function errorFunc() {
novice programmerAsked:
Who is Participating?
You can pass it in the same way you pass "id".
Is the xml in a file?
novice programmerAuthor Commented:
@louisfr - it is a XML string.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

novice programmerAuthor Commented:
@louisfr : I tried that and it did work, but not exactly how I expected. In the ajax call, i'm passing it as

 data: {xmldata : xmlString },     and in my controller method , I had to read the inputstream, because the string parameter xmldata was coming as "null".
any thoughts on this?

pubic void ReadRequest(string xmldata){
    var data = this.Request.InputStream;
It may have to do with the size of the data.
I'm going to do some tests to check that.
A ValueProviderFactory may be what you're looking for.
I found an example at
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.