帮助我在运行 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 中使用登录时,无法加载布局,请帮助我。
登录.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 == "[email protected] /cdn-cgi/l/email-protection") && (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();
}
希望能得到一个好的解决方案