Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed assistance posting data to asp.net mvc application using jquery
    primarykey
    data
    text
    <p>I've got an MVC application that accepts eitherJSON or XML objects dpending on the request type. This application is based on <a href="http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx" rel="nofollow noreferrer">this article</a></p> <p>To call a method on the MVC application that requires a complex object, I use the following Javascript (JQuery):</p> <pre><code>function GetUnassignedJob() { if (isInteger($('#txtDay').val()) &amp;&amp; isInteger($('#txtMonth').val()) &amp;&amp; isInteger($('#txtYear').val()) &amp;&amp; isInteger(intCurrentJobSummaryIndex) &amp;&amp; intCurrentJobSummaryIndex &gt; -1) { $.ajax({ type: 'POST', contentType: 'application/json; charset=utf-8', url: 'http://server/api/wip/joboptimise/getlistforids/' + $('#txtYear').val() + '/' + $('#txtMonth').val() + '/' + $('#txtDay').val(), data: $.toJSON(aJobSummary[intCurrentJobSummaryIndex].JobIds), dataType: 'json', cache: false, beforeSend: function(XMLHttpRequest) { ShowLoading(); }, success: function(data, textStatus) { try { ClearUnassignedJobs(); AddUnassignedJobs(data); } catch (e) { alert('GetUnassignedJob():\r\n\r\n' + e.message); HideLoading(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { HideLoading(); ShowStatus('unable to retrieve job list'); }, complete: function(XMLHttpRequest, textStatus) { HideLoading(); } }); } else { ShowStatus('please ensure you have entered numeric values for day, month and year'); } </code></pre> <p>}</p> <p>When deployed to the server and accessed from any client on the network - everything works fine. However, when I try to to the same from the server, I receive the following error message:</p> <p>Page Location: /api/wip/joboptimise/getlistforids/2010/3/10</p> <p>Message: Expecting element 'root' from namespace ''.. Encountered 'None' with name '', namespace ''. </p> <p>Source: System.ServiceModel.Web</p> <p>Method: System.Object InternalReadObject(System.Runtime.Serialization.XmlReaderDelegator, Boolean)</p> <p>Stack Trace: at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName) at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName) at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader) at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream) at rbm.api.ObjectFilter.ProcessJson(ActionExecutingContext filterContext)</p> <p>Some further investigation shows that the InputStream property of the HttpContext is empty! Stranger still, when I use an application like TcpTrace (so that I can see the HTTP traffic), everything works!</p> <p>Any assistance would be greatly appreciated,</p> <p>Mark</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload