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

标签 c# asp.net-mvc-4

这是 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.

最佳答案

使用==而不是等于

model.password == ob.password

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

相关文章:

c# - ASP.Net 平台是独立的吗?

c# - 从应用程序创建 Sqlite 嵌入式数据库

C# string.Split() 匹配两个斜线?

asp.net-mvc-4 - 如何使用 asp.net mvc 路由来调用不同的 ActionResult 方法并显示与实际情况不同的 URL?

C#.NET MVC4 - 方法的不可为空类型的参数的空条目

c# - 需要 BackgroundWorker 帮助

javascript - 允许用户设置 HTML 元素 CSS

c# - 从 Asp.Net MVC 4 Web API 返回 View

javascript - 在 jQuery 中禁用下拉列表

c# - 使用 Windows 身份验证连接到 SQL Server