Hi,
I have wrote an application which calls REST service using Web API.
When I debug it works fine
however when I deploy the app to program files/double click the exe from the bin/release folder
call to the REST service fails and I always get 500 status code as response.
I have posted full Source Code:
Ultra News[
^]
I am confused whether following code is causing the bug(this code works fine when debugging the app)
public IEnumerable<T> Get()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(_endpoint);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync(MethodURL).Result;
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsAsync<IEnumerable<T>>().Result;
}
else
{
throw new Exception(string.Format("Data access faild,{0} ({1}) method:{2}", (int)response.StatusCode, response.ReasonPhrase, MethodURL));
}
}
Thanks & Regards,
Nitin