首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >将异步与MVC5配合使用有什么优势?

将异步与MVC5配合使用有什么优势?
EN

Stack Overflow用户
提问于 2013-09-30 14:13:51
回答 2查看 49.9K关注 0票数 120

它们之间的区别是什么:

代码语言:javascript
复制
public ActionResult Login(LoginViewModel model, string returnUrl)
{
    if (ModelState.IsValid)
    {
        IdentityResult result = IdentityManager.Authentication.CheckPasswordAndSignIn(AuthenticationManager, model.UserName, model.Password, model.RememberMe);
        if (result.Success)
        {
            return Redirect("~/home");
        }
        else
        {
            AddErrors(result);
        }
    }
    return View(model);
}

和:

代码语言:javascript
复制
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (ModelState.IsValid)
    {
        IdentityResult result = await IdentityManager.Authentication.CheckPasswordAndSignInAsync(AuthenticationManager, model.UserName, model.Password, model.RememberMe);
        if (result.Success)
        {
            return Redirect("~/home");
        }
        else
        {
            AddErrors(result);
        }
    }
    return View(model);
}

我看到MVC代码现在有异步,但有什么不同呢?其中一个的性能是否比另一个好得多?其中一个比另一个更容易调试问题吗?我应该为我的应用程序更改其他控制器以添加异步吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19087513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档