How could I use this action as a service?
public class HomeController : Controller {
public string GetSomeValue(){
return "This is some value";
}
}
If I navigate to this URL, http://mysite.com/Home/GetSomeValue, it returns a string, without any html or markup of any kind.
So, what is to keep me from using this method as a service that returned something meaningful, say json, that I could call from anywhere?
And if this is possible, how would I do this (Say from the code behind of another asp.net web site)?
Thanks in advance.
100% Nothing wrong with doing this.
A sample application – NerdDinner – does this very same thing to load dinners restfully.
See http://nerddinner.codeplex.com/SourceControl/changeset/view/70027#874260 for controller and http://nerddinner.codeplex.com/SourceControl/changeset/view/70027#874293 for javascript file ( look for NerdDinner.FindMostPopularDinners )
e.g.
C#
JS