I have been experimenting with building a Windows ConsoleApp to be run as a WebService to sync some data back and forth I have built a project for syncing and when I ran it through my wpf project it seemed to work but not it's not.
using System; using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using System.Net.Http.Headers; using QAQC_DataCommon.Models; namespace TestApp { class Program { static void Main(string[] args) { Gettasks(); } public static async void Gettasks() { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost/QAQC_SyncWebService/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var response = await client.GetAsync("Tasks/?username=XXXXXX&LastUpdated=1/1/15"); if (response.IsSuccessStatusCode) { List<QaqcRow> ls = await response.Content.ReadAsAsync<List<QaqcRow>>(); foreach (QaqcRow qaqcRow in ls) { Debug.WriteLine(qaqcRow.GetValue("BusinessUnit")); } } } catch (Exception) { throw; } } } } }
It gets up to Var response = Await line when it just exits. No exceptions or any warnings, if I am debugging it just stops.
my output is:
The thread 0x1414 has exited with code 259 (0x103). The thread 0x16e4 has exited with code 259 (0x103). The program '[9656] TestApp.vshost.exe' has exited with code 0 (0x0). My controller from my webservice is as follows:
public IEnumerable<QaqcRow> Index(string username, string lastUpdated) { return GetFilteredList(username, lastUpdated).OrderBy(x => x.GetValue("FormId")); } I can manually go to the webservice via the link and i get data, but when i use httpclient it just dies.