View Full Version : Proxy POST payload and ASP.NET MVC

29 Sep 2011, 9:54 PM
I'm hoping someone here may have experienced this before and may be able to help. I know it's probably better put into an ASP.NET forum elsewhere but I thought i'd try.

I have an issue sending json from my sencha app to my ASP.NET MVC controller. The issue is i can't access the request payload posted by sencha from my .NET MVC controller.

Here is the Code

Ext.regModel('Trauma.Data.Models.CategorySelection', {
idProperty: 'Id',
fields: [
{ name: 'Id', type: 'int' },
{ name: 'TraumaReviewId', type: 'int' },
{ name: 'TraumaCategoryId', type: 'int' }
proxy: {
type: 'ajax',
url: '/CategorySelections/Handler/',
reader: {
type: 'json',
root: 'data'

Trauma.Data.Stores.CategorySelectionStore = new Ext.data.Store({
model: 'Trauma.Data.Models.CategorySelection'

Everything is sent fine from the sencha side of things when i call .sync(). If you look at this image of chrome, the json in the request payload.


The issue is i just can't seem to get the payload data from within the .net MVC controller. I can't find it from within the the Request Header or the FormData. Where is this payload ?

Is there a way to expose the 'data' as an parameter within the store / proxy so that the .net MVC controller can then have that data parsed to it ?

Or am i doing it wrong ???

3 Oct 2011, 7:27 PM
Anyone experienced this ?

6 Oct 2011, 2:54 PM
For anyone who may experience this issue in the future, aparently it was the way MVC was serialising the json that came back.

Here is a link to another forum that i posted the same question. I answered the problem in there and gave details.


11 Oct 2011, 5:21 PM
The DataContractJsonSerializer has a few issues with dates so i have changed it to use the Ext.Net JSON.Deserialise method.

This is a lot more forgiving with date formats sent back from the client.

filterContext.HttpContext.Request.InputStream.Position = 0;

//The data contract json serialiser has issues with dates. It expects them in a certain format and will only accept that format.
//object o = new DataContractJsonSerializer(RootType).ReadObject(filterContext.HttpContext.Request.InputStream);

//Have changed it to use a string and the Ext.Net json serialiser. This allows for different date formats and isn't so restrictive.
System.IO.Stream s = filterContext.HttpContext.Request.InputStream;
string j;
using (System.IO.StreamReader r = new System.IO.StreamReader(s))
j = r.ReadToEnd();
object o = JSON.Deserialize(j, RootType);

filterContext.ActionParameters[Param] = o;