In MVC Controller's action, write code:
HttpClient c = new HttpClient(GlobalConfiguration.DefaultHandler);
c.GetStringAsync("http://localhost/api/Values").Wait();
It will report NRE. I finally make it working with another code:
HttpClient c = new HttpClient(new HttpServer(GlobalConfiguration.DefaultHandler));
c.GetStringAsync("http://localhost/api/Values").Wait();
But it's better to throw meaningful exception in the first scenario if it's not allowed.
HttpClient c = new HttpClient(GlobalConfiguration.DefaultHandler);
c.GetStringAsync("http://localhost/api/Values").Wait();
It will report NRE. I finally make it working with another code:
HttpClient c = new HttpClient(new HttpServer(GlobalConfiguration.DefaultHandler));
c.GetStringAsync("http://localhost/api/Values").Wait();
But it's better to throw meaningful exception in the first scenario if it's not allowed.