I've created a very simple WebAPI with one get command that just returns an integer. It works perfectly fine when I run it in a browser. But when I try to access problematically from another project in the solution I get the following:
2013-05-15 17:46:47,811 - Response: StatusCode: 401, ReasonPhrase: 'Access Denied',Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Wed, 15 May 2013 16:46:47 GMT
Server: Microsoft-IIS/5.1
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
Connection: close
Content-Length: 4431
Content-Type: text/html
}
Here is the code I'm using. Any help would really be appreciated.
var client = new HttpClient { BaseAddress = new Uri(_uri) };
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = client.GetAsync(string.Format("api/Config/{0}", id)).Result;
if (response.IsSuccessStatusCode)
{
var res = response.Content.ReadAsAsync<int>().Result;
return res;
}