model.usernam-6ren">
gpt4 book ai didi

c# - 如何在 C# 中调试 "Unable to create a constant value of type ' System.Object'"?

转载 作者:行者123 更新时间:2023-11-30 23:23:17 25 4
gpt4 key购买 nike

这是 Controller

public ActionResult login(login ob)
{
bool mm = db.regs.Any(model => model.username == ob.username && model.password.Equals(ob.password));
if (mm)
{
return RedirectToAction("welcome");
}
else
{
@ViewBag.err = "Invaid";
}
return View();
}

Controller 中的错误是

Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.

最佳答案

使用==代替Equals

model.password == ob.password

关于c# - 如何在 C# 中调试 "Unable to create a constant value of type ' System.Object'"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38429777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com