【发布时间】:2019-11-10 06:14:20
【问题描述】:
当我从控制台应用程序运行它时,我正在连接到 API 并使用异步库 (Koenzomers),它工作得非常好,当我从 asp.net webform 页面运行它时,我无法让它工作.
我的代码
如果我在从控制台应用程序运行时尝试运行任务
Task TestAuth = TestOtherLibrary();
TestAuth.Wait();
我得到了同样的结果。
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Authenticating");
RegisterAsyncTask(new PageAsyncTask(Auth));
}
public async Task Auth()
{
using (KoenZomers.UniFi.Api.Api UnifiApp = new KoenZomers.UniFi.Api.Api(new System.Uri("https://myserverurl"), "unifisiteid"))
{
await UnifiApp.Authenticate("admin", "mysecurepassword");
}
}
思路是连接unifi控制器,根据mac地址授权用户
目前,我的页面加载陷入僵局,不确定 UI 是否正在等待任务结束,而且它永远不会结束。
【问题讨论】:
标签: c# asp.net asynchronous webforms