Paolo ponzano - 510 - Dec 17, 2013

Hello, I’ve got some issues using ServiceStack with jquery… if I use a DTO Request that has some complex field as

 public class MyInner
        public int Code { get; set; }
        public string MCUserid { get; set; }

    public class MyDTO
        public int SomeNumber { get; set; }

        public MyInner Content { get; set; }

On the request I’ve Content = null… is there any particular reason? I’ve tried to follow this but with no luck… I’m under v4


Stefan Tsalapatis:

Are you sure that  it is not problem with CORS ? It works with simple object ? Have you try with $.ajax ? with v.3 and $.ajax (and CORS in my case) I had not problem with objects including lists of others.

If you’re trying to send complex type objects, make sure you’re sending it as JSON instead of the default form-urlencoded. I would just stick to jquery $.ajax client which is more popular and flexible. Whenever you have interoperability issues like this you also want to use a http sniffer like Fiddler, Chrome Web Inspector or WireShark so you can see that you’re actually sending matches what you think you’re sending. This is also useful for others to see what’s going on and so they are able to help identify the issue.

If you’re still having issues can you post the javascript code you’re using, as well as the HTTP Request/Response headers (e.g. using WebInspector or Fiddler) so we can see what’s going on.

Posting on StackOverflow is better for viewing source code and HTTP Headers. You can post the link to the question here so we can find it.

paolo ponzano:

Hello, after some test, voodoo and the hint of Stefan I managed that I need to enable CORS ( now it works! Thanks