我不能真正找出代碼中我需要設置我的「等待」,所以它運行我的代碼,以使用戶登錄到該網站。在那裏我需要設置我的等待代碼
問題出在哪裏,當用戶成功登錄網站時,應該在哪裏設置「等待」。
錯誤:
'UserLogin' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'UserLogin' could be found (are you missing a using directive or an assembly reference?)
[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");
在該邏輯分支中,似乎沒有任何要等待的東西。 'UserValue'只是一個'UserLogin'對象,不需要等待。 –
實際上,至少從我們這裏可以看出,似乎根本沒有什麼需要等待的東西。 –
@GlorinOakenfoot你完全用你寫的是什麼? /在這裏向我解釋? –