安全登录... [英] Logging in securely ...
本文介绍了安全登录...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试读取登录信息,并根据Jet数据库中存储的用户名和密码对它们进行验证.
稍后我想使用SQL Server数据库,但是,我遇到了安装问题,因此我暂时使用Access.
I am trying to read logon information and validate them against stored user name and passwords within a Jet database.
Later I want to use an SQL Server database, however, I have an installation problem, so I am using Access temporarily.
Logon.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection ConnectionToOleDb = new System.Data.OleDb.OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0;|DataDirectory|LibrarySystem.accdb");
try {
//1. connect to database
ConnectionToOleDb.Open();
//2. read logon credentials and match them to input
???
}
catch (Exception ex) { throw ex; } //strongly typed errors need to be included..
finally
{
ConnectionToOleDb.Close();
}
...
Logon.aspx
function Submit1_onclick() {
/* Logon credentials to be submitted and verified by the server control */
var user = document.getElementById('user').Value;
var pwd = document.getElementById('pwd1').Value;
if (user == "user") && (pwd == "password")
{
return true;
document.forms[0].submit();
}
web.config
...
web.config
...
<configuration>
<connectionstrings>
<add name="CustomerDataConnectionString">
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=|DataDirectory|LibrarySystem.accdb"
providerName="System.Data.OleDb" />
</add></connectionstrings>
...</configuration>
推荐答案
不要在页面加载中执行任何操作.您应该在按钮单击事件"中创建连接并匹配凭据.
请参考具有访问权限数据库的登录表单 [ ^ ].
Don''t do anything in Page Load. You should create Connection and match credentials inside Button Click Event.
Refer- Login form with access database[^] for one example.
这篇关于安全登录...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文