I have created a simple web api and when I access this from IE the web api returns exactly what I expected. However, now I tried to access the same web api from a web forms application using httpclient. But now I get a 404 error. But the api seems to work, because I do receive results when using a browser. Any ideas what goes wrong? This is the code:
HttpClientHandler handler = new HttpClientHandler()
{
UseDefaultCredentials = true
};
HttpClient client = new HttpClient(handler);
client.BaseAddress = new Uri("http://server/appdir");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("/api/environment").Result;
client.GetAsync("/appdir/api/environment/").Result;?