我的服务中有以下代码:
// add Txt record to DNSimple with verification text
await CreateDomainRecordAsync(domain, new DomainRecordDto
{
//....
});
// verify domain on Office365
await _office365domainService.VerifyDomainAsync(domain);
第一个操作是调用端点 #1(域注册者)并将 TXT 记录添加到域。第二个操作是调用端点#2(Office365),它验证域注册器中是否存在TXT记录。
此代码不起作用,我在第二次操作时遇到异常,即 TXT 记录不存在。
我创建了测试代码:
public IActionResult LongOperation()
{
Thread.Sleep(10 * 1000);
return Ok();
}
public IActionResult Test()
{
return Ok();
}
并称之为:
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri("http://test***.azurewebsites.net/home/");
await httpClient.GetAsync("LongOperation");
}
using (HttpClient httpClientLocal = new HttpClient())
{
httpClientLocal.BaseAddress = new Uri("https://localhost:44366/Home");
await httpClientLocal.GetAsync("Test");
}
它按我的预期工作,调用第一个方法,在执行“LongOperation”时等待 10 秒,然后调用“Test”方法。
为什么我的带有域的真实代码不等待以及如何正确执行?
湖上湖
相关分类