简体   繁体   English

如何使用ASP.NET WebForms和现有SQL Server数据库实现登录功能?

[英]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.

相关问题 使用WebForms的ASP.Net Identity到现有SQL数据库 - ASP.Net Identity with WebForms to existing SQL database Asp.net使用SQL Server数据库登录 - Asp.net login with SQL Server database 如何在ASP.NET MVC Core中使用数据库优先方法在现有数据库中实现Asp.net身份 - How to implement Asp.net identity with existing database using database first approach in asp.net mvc core 如何在现有数据库中实现ASP.NET Identity 2.0? - How to implement ASP.NET Identity 2.0 in existing database? 在 ASP.NET webforms 前端自动加载新插入的行(SQL Server 数据库)? - Automatically load newly inserted rows (SQL Server database) in ASP.NET webforms front-end? 如何在示例C#ASP.NET WebForms应用程序中将登录数据库更改为PostgreSQL - How to change login database to PostgreSQL in sample C# ASP.NET WebForms application 在ASP.NET(C#)中使用SQL Server数据库登录表单 - Login form with SQL Server database in asp.net (C#) 使用ASP.NET Web表单通过自定义登录阻止对文件夹的访问 - Block access to folder with custom login using asp.net webforms 如何在Asp.Net Webforms中实现插件体系结构 - How to implement plugin architecture into Asp.Net webforms 如何在asp.net webforms中正确实现PRG模式 - How to implement PRG pattern properly in asp.net webforms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM