小编m.r*_*fca的帖子

发送电子邮件异步:在异步操作仍处于挂起状态时完成异步模块或处理程序

我正在尝试从Controller发送电子邮件异步并收到以下错误:

希望等待电子邮件发送给完成动作.

在异步操作仍处于挂起状态时完成异步模块或处理程序.

这是我实现我使用还试图void代替async Task

public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    var user = await _userManager.FindByNameAsync(model.Email);
    if (user != null)
    {
        if (!await _userManager.IsEmailConfirmedAsync(user.Id))
        {

            //dont want to await result
            //just send email 
            _mailService.SendAccountConfirmationEmailAsync(user);
            ...
        }
        ...
    }
    return View();
}
Run Code Online (Sandbox Code Playgroud)

.

public async Task SendAccountConfirmationEmailAsync(ApplicationUser user)
{
    dynamic email = GetAccountConfirmationEmailTemplate();

    email.Username = user.Email;
    email.Name = user.UserName;
    email.To = user.Email;
    email.AccountConfirmationUrl = await GetAccountConfirmationUrl(user);

    await _mailService.SendAsync(email);
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

c# asp.net-mvc async-await

1
推荐指数
1
解决办法
1465
查看次数

检查无限制的互联网访问

在您访问互联网之前,某些公共无线网络会将您重定向到登录页面.我不仅要测试系统是否具有互联网连接,还要测试它是否无限制,即没有重定向到这样的登录页面.

我已经检查了属性,HttpWebResponse找到可能表明这一点但却一无所获的东西.

我怎么知道我没有被重定向到提供商的登录页面?

c#

0
推荐指数
1
解决办法
504
查看次数

标签 统计

c# ×2

asp.net-mvc ×1

async-await ×1