So, I have an action on a controller in my MVC3 website that I’m using as a service. The return type is string, and I’m wondering what would be the best way to consume this?
public class HomeController : Controller {
public string GetSomeValue(){
return "This is some value";
}
}
Should I use the WebClient class, and if so, what method would be best suited for this? I’ve never used this class before and it looks a little hairy?
This question is part 2 of this question.
You could either use WebClient or the WebRequest object if you want to call your service from the server.
If you just want to read a string you could use it like this: