如何在web.config中给出代码以检索sql登录表? [英] how to give code in web.config to retrieve sql login table?

查看:55
本文介绍了如何在web.config中给出代码以检索sql登录表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

btnlogin ..

btnlogin..

if (FormsAuthentication.Authenticate(this.txtUsername.Text, this.txtPwd.Text))
            Response.Redirect("Welcome.aspx");
        else
            lblMessage.Text = "<br><b>Invalid Login..Please reenter....";



webconfig ..



webconfig..

<authentication mode="Forms">
            <forms name="Welcome" path="Welcome.aspx" loginUrl="Login.aspx" protection="All" timeout="30">

                <credentials passwordFormat="Clear">
                    <user name="zaheer" password="zaheer"/>
                    <user name ="fahad" password="fahad"/>
                </credentials>
            </forms>
        </authentication>
        <authorization>
            <allow users="*"/>

        </authorization>


您好这是web.config代码..如何从数据库表中检索.实际上我不想在Web config中提供用户名和密码.我只想从sql表中检索用户名和密码.还有一件事是如何验证用户名和密码有效,并且den必须重定向到另一页?.hw做dat ??


hi this is web.config code..how to retrieve from database table.actually i dont want to give username and password in web config.i want to retrieve username and password from sql table only.and one more thing is how to validate username and password is valid and den have to redirect to another page?.hw to do dat??

推荐答案



首先,如果将数据库凭据添加到数据库中,那么如何登录到数据库?因此,您仅需要配置文件中的数据库登录信息.您可能会担心安全问题.但是您可以使用 aspnet_regiis 命令对连接字符串信息进行加密.

对于第二个问题,验证后要重定向的是使用您的自定义类函数.如果发生 SqlException ,则表明您的数据库凭据不正确.因此您需要捕获特定的异常类型.

希望这对您有帮助...

谢谢
-amit.
Hi,

first of all, if you add your database credential in database then how can you login into your database ? so you need database login information in config file only. you may be worry about security issue. but you can encrypt connectionstring information using aspnet_regiis command.

for your second question, about to redirect after validating is using your custom class function. if SqlException occur it means that your database credential is incorrect. so you need to catch particular exception type.

hope this will help you...

thanks
-amit.




这会有所帮助吗? [
Hi,

This will be helpful?[^]


这篇关于如何在web.config中给出代码以检索sql登录表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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