views:

37

answers:

1

I am hoping someone can point me in the right direction here. I am trying to create web service that will return ajaxified results. Specifically, I want to write a web service that will fetch email through a secure connection. However, rather then have the web service return every single email, I just want to fetch maybe 5 emails at a time. I've always used Ajax as a client helper technology and not sure how to go about implementing this on a server side, or if its even possible. Can someone please point me to some ideas or some suggestions on how I can accomplish this?

I am using ASP.NET/C#, by the way.

+1  A: 

There are a number of ways to return "ajaxified" results (JSON) from a web/wcf services. A WebServices have the attribute [ScriptMethod(ResponseFormat = ResponseFormat.Json)] you can use (and find some examples), WCF services may be configured to return JSON (here is a nice post: http://www.west-wind.com/Weblog/posts/164419.aspx)

But actually I prefer to use ASP.NET MVC to do this. Basically all you need to do in this case is to say return Json(myObject); inside your controller's method.

Here is an example: http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=399 And here is the StackOverflow question about it: http://stackoverflow.com/questions/227624/asp-net-mvc-controller-actions-that-return-json-or-partial-html

The returned JSON is standard and can be consumed on the client using any library (jQuery, etc) and in your controller you do all you want and return what you want.

Patrol02