帮我解决当我运行ASP.NET项目时出现的错误。
MissingMethodException: Method not found: 'Boolean Microsoft.AspNetCore.Cryptography.UnsafeNativeMethods.CryptProtectData(Microsoft.AspNetCore.Cryptography.DATA_BLOB*, IntPtr, Microsoft.AspNetCore.Cryptography.DATA_BLOB*, IntPtr, IntPtr, UInt32, Microsoft.AspNetCore.Cryptography.DATA_BLOB ByRef)'.
当我在我的 .NET 6 项目中使用 <login>
进行登录时,无法加载布局,请帮帮我。
Login.cshtml
<form method="post">
<div class="col-12">
<div class="mb-3">
<label class="form-label">Email</label>
<input type="email" class="form-control" id="yourUsername" name="username"/>
<div id="ErrorEmail" style="color: red;" class="form-text"></div>
</div>
</div>
<div class="col-12">
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Mật Khẩu</label>
<input type="password" class="form-control" id="yourPassword" name="password" />
<div id="ErrorPassword" style="color: red;" class="form-text"></div>
</div>
</div>
<div class="col-12">
<button class="btn btn-primary w-100" id="Btn_Login" type="submit">Đăng Nhập</button>
</div>
</form>
账户控制器
[HttpPost]
public async Task<IActionResult> Login(string username, string password, string ReturnUrl)
{
if ((username == "Admin@gmail.com") && (password == "Admin"))
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.Name, username)
};
var claimsIdentity = new ClaimsIdentity(claims, "Login");
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity));
return RedirectToAction("Index", "Home");
}
else
return View();
}
我希望能得到一个好的解决方案