Results 1 to 2 of 2

Thread: Json return from Asp.Net WebApi

  1. #1

    Default Json return from Asp.Net WebApi

    Hi I installed the application tutorial Modern-Tunes and all works fine.

    When I call the ITunes service with

    Code:
    proxy: {
            type: 'jsonp',
            url: 'https://itunes.apple.com/us/rss/topmusicvideos/limit=4/json',
            reader: {
                type: 'json',
                rootProperty: 'feed.entry'
            }
        }
    and analize the response with chrome developers tools, I see this Response:

    Ext.data.JsonP.callback1({"feed":{"author":{"name":{"label" .......... etc etc })

    Here the call to ITunes service:
    https://itunes.apple.com/us/rss/topm...sonP.callback1

    All works fine (the grids present in Modern-Tune app are correctly populated).


    Now I tried to extend the Modern-Tunes application with a new call to my WebApi class with:

    Code:
        proxy: {
            type: 'jsonp',
            url: 'https://localhost:44393/api/vinileobj',
            reader: {
                type: 'json'
            }        
        }
    to call GET action on my running .Net application.

    And here the .Net controller:

    Code:
        public class VinileObjController : ApiController {
            
            public List<Vinile> Get() {
                Vinile v1 = new Vinile();
                v1.Id = "1";
                v1.Title = "Attenti al lupo";
                v1.Artist = "Lucio Dalla";
    
                Vinile v2 = new Vinile();
                v2.Id = "2";
                v2.Title = "Cirano";
                v2.Artist = "Francesco Guccini";
    
                List<Vinile> listaVinili = new List<Vinile>();
                listaVinili.Add(v1);
                listaVinili.Add(v2);
    
                return listaVinili;
            }
    
        }
    Here the call: https://localhost:44393/api/vinileob...sonP.callback2

    The new call works fine but when I analyze the Response using chrome developers tools I see that:

    [{"Id":"1","Title":"Attenti al lupo","Artist":"Lucio Dalla"},{"Id":"2","Title":"Cirano","Artist":"Francesco Guccini"}]

    The Response does not contain the callback Ext.data.JsonP.callback2 and I do not understand why!


    Can someone help me to understand the problem?

    Thanx

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,254
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Tags for this Thread

Posting Permissions

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