与代码

时间:2015-11-23 20:27:23

标签: c# asp.net-mvc asynchronous

我无法真正找到代码中我需要设置“等待”的位置,以便运行我的代码以使用户能够登录该站点。

问题出在哪里,当用户登录网站成功时,我应该在哪里设置“等待”。

错误:

  

'UserLogin'不包含'GetAwaiter'的定义,没有   扩展方法'GetAwaiter'接受类型的第一个参数   可以找到'UserLogin'(你是否错过了使用指令或者   装配参考?)

[HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public async Task<ActionResult> login(UserLogin UserValue)
    {
        //Makes database access
        DataLinqDB db = new DataLinqDB();

        if (ModelState.IsValid)
        {
            //Is this email and also downloads "salt" from the mail.
            var email = db.brugeres.FirstOrDefault(i => i.brugernavn == UserValue.Brugernavn);
            if (email != null)
            {
                //Makes password on the SHA256
                var pass = HelperClass.Helper.Hash.getHashSha256(UserValue.Brugernavn);

                //Checker up for a username and password match up with what you have written in. 
                //Checks also while on the salt as the few from the past to the fit with "email"
                var User = db.brugeres.FirstOrDefault(u => u.brugernavn == UserValue.Brugernavn && u.adgangskode == pass && u.salt == email.salt);
                if (User != null)
                {
                    .... code her ....
                    //Sending me over to the front. (the closed portion.)

                    await UserValue; //Error here!!!
                    return RedirectToAction("index");

                }
                else
                {
                    //Error - Invalid username and password do not match.
                    ModelState.AddModelError("", "Unfortunately, it is wrong ..");
                }
            }
            else
            {
                //Error - Invalid username do not match.
                ModelState.AddModelError("", "We could not find you!");
            }
        }
        return View();
    }

这里存在错误。

//Sending me over to the front. (the closed portion.)
await UserValue;//Error here!
return RedirectToAction("index");

0 个答案:

没有答案