I have a .NET Core ASP.NET MVC 6 application, and I'm sure this is a bug in Visual Studio. If I place a breakpoint after the wait statement, the object does not appear in the locales, and I cannot hover over the check. But if I use a variable, it still works fine, and it is definitely full.
Something simple:
public async Task<IActionResult> Index()
{
var location = await _listingLocationService.GetLocationByAddress("123 Fake Street");
return Content(location.Latitude.ToString() + " " +location.Longitude.ToString());
}
If I put a breakpoint in the return statement, I cannot check the location. He does not appear anywhere. I can even remove the wait and put the .Result result at the end, and still nothing is displayed. But when I continue, the view shows location.latitude and location.longitude fine. Therefore, I know that it is populated.
For completeness, I will also include the GetLocationByAddress function, which does the same, if I put a breakpoint somewhere after waiting, I cannot check the variables (even the deserialized list!).
public async Task<Geolocation> GetLocationByAddress(string address)
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://maps.googleapis.com/maps/api/geocode/json");
var request = new HttpRequestMessage(HttpMethod.Get, "?address=" + WebUtility.UrlEncode(address) + "&key=...");
var response = await client.SendAsync(request);
var contents = await response.Content.ReadAsStringAsync();
var locationResult = JsonConvert.DeserializeObject<GoogleLocationResult>(contents);
if (locationResult.status == "OK")
{
var result = locationResult.results.First().geometry.location;
return new Geolocation
{
Latitude = result.lat,
Longitude = result.lng
};
}
else
{
return null;
}
}
}
source
share