Results 1 to 4 of 4

Thread: Proxy POST payload and ASP.NET MVC

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    11

    Default Proxy POST payload and ASP.NET MVC

    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
    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.

    Untitled.jpg

    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 ???
    Attached Images Attached Images

  2. #2
    Sencha User
    Join Date
    Nov 2010
    Posts
    11

    Default Bump For Help ?

    Anyone experienced this ?

  3. #3
    Sencha User
    Join Date
    Nov 2010
    Posts
    11

    Default Found an answer

    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.

    http://forums.asp.net/t/1726344.aspx...load+in+chrome

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    11

    Default Further more.

    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.
    Code:
    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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •