【问题标题】:Pass usercode and returns username with filled field传递用户代码并返回带有填充字段的用户名
【发布时间】:2019-02-27 20:48:24
【问题描述】:
我在返回用户名时遇到了一些不寻常的问题..
我正在简要介绍一下,
我正在开发网络应用程序门户。
我正在提供登录页面..
在登录页面..用户应该输入他的登录代码..然后他会自动填写用户名字段..只需要输入密码,如果一切顺利..他在仪表板上..
我正在使用实体框架代码优先方法..我在 linq 查询中遇到问题..
如何验证用户代码并在填写的字段中返回用户名并再次传递密码并验证
【问题讨论】:
-
请edit 提出问题并提供相关代码(C# 和 .cshtml)显示您尝试过的内容,否则我们将无法提供帮助。
-
请Edit提问。您现在正在制造混乱,有可能在没有收到答案的情况下关闭它。此外,您在下面发布的“答案”不是答案 - 您应该永远将澄清或补充作为“答案”发布。
标签:
asp.net-mvc
linq
asp.net-mvc-5
entity-framework-6
linqpad
【解决方案1】:
您不应将变量 USERCODE 放在引号中,因为它将被视为包含值“USERCODE”的字符串。
public ActionResult GETUSERNAME(string USERCODE)
{
Dbconnects con = new Dbconnects();
// LoggedUserName
try
{
var user = con.webusers.FirstOrDefault(x => x.w_usr_code == USERCODE);
if (user != null)
{
}