如何控制登录 [英] how to Control a log in

查看:58
本文介绍了如何控制登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我创建了一个自定义生成的文件,让我可以使用用户名和密码。

如下:

So I created a custom generated file that lets me take the username and password.
It is the following:

public User GetUserByUserNamePassword(string userName, string Password)
{
   return (_DatabaseContext.Users.FirstOrDefault(user => user.Username == userName && user.Password ==Password));
}



在我的登录页面中,我有一个webUserControl,其中包含两个文本框,一个用于密码,另一个用于用户名。我为webusercontrol创建了一个对象数据源来接收参数用户名和密码。



什么是c#代码,可以让我检查用户名和密码是否有效(我有一个名为User btw的表,有三列,UserID(pk),用户名和密码。


In my log in page I have a webUserControl that contains two textboxes, one for the password and the other one for the username. I created an object data source for the webusercontrol to take in parameters Username and password .

Whats the c# code that can let me check if the username and password are valid (I have a table called User btw that has three columns, UserID(pk), Username and Password.

推荐答案

你应该检查这些......

C#中的登录表单验证 [ ^ ]

http://stackoverflow.com/questions/549/the-definitive-guide-to -forms-based-website-authentication [ ^ ]

http://msdn.microsoft.com/en-us/library/aa702565。 aspx [ ^ ]

验证c#中的用户名和密码表格 [ ^ ]
You should check these..
Login Form Validation in C#[^]
http://stackoverflow.com/questions/549/the-definitive-guide-to-forms-based-website-authentication[^]
http://msdn.microsoft.com/en-us/library/aa702565.aspx[^]
verify user name and password in c# form[^]


我解决了这个问题,我只需要处理我的DataSourceObject.Select()。

如果它返回null ,那么数据无效。但是如果条目是正确的,它将返回对象,在这种情况下,它是用户。



感谢您的帮助!
I solved the problem, I just have to work on my DataSourceObject.Select() .
If it returns null , then data not valid. But if The entries are correct , it returns the object which in this case it's a user .

Thanks for your help!


这篇关于如何控制登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆