1. #1
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Boulder, CO
    Posts
    538
    Vote Rating
    7
    DavidThi808 is on a distinguished road

      0  

    Default Access error reading JSON from local IIS server

    Access error reading JSON from local IIS server


    Hi all;

    I have the Hello Ext app running fine. But I changed the store/Users.js from (works great):

    Code:
     proxy: {
            type: 'ajax',
            api: {
                read: 'data/users.json',
    to:
    Code:
     proxy: {
            type: 'rest',
            api: {
                read: 'http://localhost:11523/Service1.svc/GetEmployee/1',
    I tried both ajax and rest. In both cases I got:


    [COLOR=red !important]XMLHttpRequest cannot load http://localhost:11523/Service1.svc/...art=0&limit=25. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

    Any ideas why?

    thanks - dave[/COLOR]

  2. #2
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Boulder, CO
    Posts
    538
    Vote Rating
    7
    DavidThi808 is on a distinguished road

      0  

    Default


    Running Fiddler it shows I am doing an OPTIONS and it is returning a HTML page with a paragraph saying "Method not allowed."

    However, when I use the browser going to http://localhost:11523/Service1.svc/GetEmployee/1 Fiddler says that's a get and it is successful.

    So, what's going on where it does an OPTIONS instead of a GET? And what do I need to do in my service to handle the OPTIONS request?

    thanks - dave

  3. #3
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,156
    Vote Rating
    190
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      1  

    Default


    Sounds like it's trying to do a cross-domain data request. Even going from localhost to localhost:port will kick off the cross-domain issues.

    Ultimately will you be retrieving a data resource from another domain?
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

    C
    heck out all of the 2013 SenchaCon presentations here:
    http://www.sencha.com/blog/senchacon...now-available/

  4. #4
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Boulder, CO
    Posts
    538
    Vote Rating
    7
    DavidThi808 is on a distinguished road

      0  

    Default


    Yeah, looks like it's the cross domain request. In production, this will not be a problem as everything is in the same place. But for development it is distinct systems. Boy this is a PITA (not Ext JS - the whole security thing).

  5. #5
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    24
    Vote Rating
    11
    Kyle2123 will become famous soon enough

      0  

    Default


    If I was you, I'd go with Ext.Direct.Mvc for this. It lets you avoid all of the security/configuration hassles of dealing with WCF. Basically with Ext.Direct, you'll have an ASP.NET MVC app instead of a WCF project. You can create multiple controllers, and those controllers have actions/methods. So you'll create methods to do the usual CRUD stuff. It's much more lightweight than WCF, so you'll spend less time dealing with WCF and more time focusing on what your app needs to do. With an ExtJS app, the bulk of your logic will be on the client anyway, so all your server methods will probably be doing anyway is the usual CRUD, validation, and then returning back some Json.

    Where Direct comes in is, it will generate method stubs for you to call these methods easily. It also handles the conversion of parameter input into the appropriate .NET types on the server side, etc. So for each MVC controller method, you'll have a method stub created for you in your client side code in the format Server.ControllerName.MethodName - for example, Server.Customers.Load(). It's pretty easy, and it also gives you a nice perf boost because Ext.Direct bundles multiple server calls that happen in quick succession into a single packet, which helps if you're network latency isn't very good.

  6. #6
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Boulder, CO
    Posts
    538
    Vote Rating
    7
    DavidThi808 is on a distinguished road

      0  

    Default


    Hi;

    Thank you for the suggestion. Where is the system you suggest for this? Google shows https://code.google.com/p/ext-direct-mvc/, https://github.com/elishnevsky/ext-direct-mvc, http://www.sencha.com/forum/showthre...or-ASP.NET-MVC, and more.

    thanks - dave

  7. #7
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    24
    Vote Rating
    11
    Kyle2123 will become famous soon enough

      0  

    Default


    I think the author has moved the code several times over the last few years as development has gone on so all of those are probably different versions of the same thing. There is a huge thread on it in the Ext.Direct forms. Reading the thread, or at least the more recent stuff at the end of it, will point you to whatever the newest is. Here is the link:

    http://www.sencha.com/forum/showthre...or-ASP.NET-MVC

Thread Participants: 2