当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - 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.

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.

I am mainly looking to implement Login functionality on my WebApp. How do I access the SQL database and implement Login?

I have currently connected the database and used ADO.NET Entity Model to access the database. 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.

网友答案:

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

网友答案:

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. the Login control for example uses it internally by calling Membership.Validate(username, password) for example.

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: