Last post Apr 21, 2012 10:29 AM by imran_ku07
Apr 20, 2012 12:16 PM|robertmazzo|LINK
I'm wondering if I'm missing something obvious, so please help me if you can.
All the tutorials and sample Web API projects are very useful, however I noticed that they all incorporate the client-side (i.e. chtml and jquery calls) in the same project.
If I truly want to separate my web api from the client, how do I publish a Web API service for other .net projects to consume ?
I don't have much experience with .net services, hence I may be missing something obvious - so please excuse me.
thanks in advance.
Apr 20, 2012 12:43 PM|digitalpacman|LINK
All the examples would work just fine in outside projects.
If you are asking how server-2-server they would know of your data types, you can have a published DLL that has all the types they will need in it.
Apr 20, 2012 02:13 PM|panesofglass|LINK
A shared models assembly, as noted by @digitalpacman, should work. If you are looking for something more like the SOAP coupling offered by WCF, you could take a look at hosting HttpServer in a WindowsService. HttpServer is the base for both selfhost and
webhost, but it will not run formatters by default. You'll still need to share a models assembly for this to work.
Apr 20, 2012 02:51 PM|robertmazzo|LINK
Thank you for those two responses, folks.
I hear the video presenter mentioned the term "service" from time to time, but there's never any mention of how to publish that service for clients to consume. i.e. I only see jow jquery calls into the controllers, and subsequently how jquery then receives
back the JSON-formatted data to be rendered on the client.
One suggestion I'm hearing here is to publish a DLL, and another is to use WCF-style services.
In the end, what is the real advantage by using Web API versus say a straight asp.net mvc 4 project to build my website ?
Thanks again for your patience in helping me to understand.
Apr 21, 2012 10:29 AM|imran_ku07|LINK
I hear the video presenter mentioned the term "service"
I only see jow jquery calls into the controllers, and subsequently how jquery then receives back the JSON-formatted data to be rendered on the client.
The fact is that jquery calls are just client requests from a browser. You can do the same from any .NET projects using HttpContent class ('System.Net.Http.Formatting' nuget package) or simply native WebClient/WebRequest classes. What your .NET client projects
need is just a resource(url). A resource might be refer an ASP.NET host(IIS, Cassini, IIS-Expresss, etc) or Self Host(Console, Windows, WPF, Windows
Service, etc). For self hosting here is a