Hallo die Ansicht kann nicht ausgelöst werden, aber es ist bereits seinen Controller getroffen. Ist es ein Deadlock? Weil ich GetAsync verwende, um die HttpResponse-Nachricht zu erhalten. Hier ist mein Code.MVC-Controller kann die Ansicht nicht auslösen
private bool GetCoordinates(string address)
{
bool result = false;
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(HttpUtility.UrlPathEncode("http://locationInfo/GetLocation?address=" + address));
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("").Result;
if (response.IsSuccessStatusCode)
{
JObject objs = JObject.Parse(response.Content.ReadAsStringAsync().Result);
int count = 0;
string[] cor = new string[2];
foreach (var item in objs)
{
if(item.Key.ToString() == "location") {
foreach (var it in item.Value)
{
if (count <= 1)
{
cor[count] = it.ToList()[0].ToString();
}
count++;
}
}
}
Xcor = cor[0];
Ycor = cor[1];
result = response.IsSuccessStatusCode;
}
response.Dispose();
client.Dispose();
return result;
}
}
-> Der Index kann die Ansicht nicht anzeigen.
Sie geben 'bool' zurück, also wie eine Ansicht gezeigt wird? – Mairaj
Dies ist nur eine Funktion, die innerhalb des Controllers –
aufruft. Auch den Controller-Code anzeigen. – Mairaj