3 ms·
> In .NET, you have to install the WCF REST stack Well you don't have to. If I was just writing services to only return JSON to a web-page, I would just use AS
by JonoW 15y ago
> In .NET, you have to install the WCF REST stack
Well you don't have to. If I was just writing services to only return JSON to a web-page, I would just use ASP.NET MVC which has good built in support for this, e.g.
public class MyController : Controller {
public ActionResult MyJsonAction(){
return Json(new {
Id = 1,
Name = "MyName"
});
}
}
Now you have a url /MyController/MyJsonAction which will return the JSON string { Id: 1, Name: "MyName" }, no stress.
WCF is complicated, but it is powerful too, especially if you need to support multiple bindings (e.g. REST and SOAP endpoints for the same service). Also, if you need to support the SOAP WS-* standards, it's a life-saver.
- teyc 15y agoThanks. I'm new to MVC. Sounds like MS got their act together on this one. Complicated is usually overkill for a startup though. This means a big swath of .NET technology is simply not applicable.