[英]How to implement Login functionality using ASP.NET WebForms and existing SQL Server database?
I have a SQL Server database that I made using Visual Studio's LocalDB. 我有一个使用Visual Studio的LocalDB创建的SQL Server数据库。 It has 5 tables, one for the Employee information and credentials, one for the location codes of the offices of the company and others for the meetings he attended and the tasks assigned to him.
它有5个表,一个用于员工信息和凭证,一个用于公司办公室的位置代码,另一个用于他参加的会议以及分配给他的任务。
I am mainly looking to implement Login functionality on my WebApp. 我主要是希望在我的WebApp上实现登录功能。 How do I access the SQL database and implement Login?
如何访问SQL数据库并实现Login? I have currently connected the database and used ADO.NET Entity Model to access the database.
我目前已连接数据库并使用ADO.NET实体模型来访问数据库。 I am looking to avoid stored procedures.
我希望避免存储过程。 It would be best if the someone explained how to do this with ADO.NET Entity Model and the Login control.
如果有人解释了如何使用ADO.NET实体模型和Login控件执行此操作,那将是最好的。
You have to create your own table with login credential{like username, password,role(if you want to set)}, then after just connect your table with the login template to check the credential. 您必须使用登录凭据{如用户名,密码,角色(如果要设置)}创建自己的表,然后将表与登录模板连接以检查凭证。
These links will help you out: 这些链接将帮助您:
http://www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-Asp-Net-3-5/ http://www.aspsnippets.com/Articles/Simple-User-Login-Form-example-in-ASPNet.aspx http://www.c-sharpcorner.com/uploadfile/raj1979/login-control-in-Asp-Net-3-5/ http://www.aspsnippets.com/Articles/Simple-User-Login-Form-例如合ASPNet.aspx
you can just use Membership class, install the required db objects via aspnet_regsql or automatically created if it does not exist by the framework. 您可以只使用Membership类,通过aspnet_regsql安装所需的db对象,或者如果框架不存在则自动创建。 the Login control for example uses it internally by calling Membership.Validate(username, password) for example.
例如,Login控件通过调用Membership.Validate(用户名,密码)在内部使用它。
Otherwise, if you insist to use another data framework such as entity model then you may create your own table for storing users, roles etc. there should be plenty examples of this. 否则,如果您坚持使用其他数据框架(如实体模型),那么您可以创建自己的表来存储用户,角色等。应该有很多这方面的例子。 You still can use the Login control and handle the event such as LoggingIn, LoggedIn to plug in your own codes.
您仍然可以使用Login控件并处理事件,例如LoggingIn,LoggedIn以插入您自己的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.