A simple Asp.net single-point login implementation

Source: Internet
Author: User

The following is an implementation:


First, click the train ticket booking link to open the http: // Student Information Platform website/logstores trainsite. Asa page.

Overview of the logstores trainsite. Asa pageCodeAs follows:

Copy code The Code is as follows: <%
Response. Buffer = true
Response. expiresabsolute = now ()-1
Response. expires = 0
Response. cachecontrol = "no-Cache"
Response. addheader "Pragma", "No-Cache"

// Obtain the user name and password based on the user session
%>
<HTML>
<Body>
<Div style = 'display: none'>
<Form name = "myform" method = "Post" Action = "http: // train ticket booking website/loginfromothersite. aspx">
<Input type = "hidden" name = "username" value = "<% = username %>"/>
<Input type = "hidden" name = "userpwd" value = "<% = userpwd %>"/>
</Form>
</Div>
</Body>
</Html>
<Script language = "JavaScript">
Myform. Submit ();
</SCRIPT> the code for the loginfromothersite. aspx. CS page is roughly as follows:

Using (sqlconnection conn = new sqlconnection (sqlhelper. studentconnectionstring ))
{
String SQL = "select t_stuuser.id, t_stuuser.stunumber, t_stuuser.userpassword, t_stuuser.realname, v_stuuser.classname, v_stuuser.departmentname"
+ "From t_stuuser, v_stuuser where t_stuuser.stunumber = @ username and t_stuuser.userpassword = @ userpwd and v_stuuser.stunumber = @ username ";
Sqlcommand cmd = new sqlcommand (SQL, Conn );
Sqlparameter pusername = cmd. Parameters. Add ("@ username", sqldbtype. varchar, 30 );
Sqlparameter puserpwd = cmd. Parameters. Add ("@ userpwd", sqldbtype. varchar, 150 );
Pusername. value = request. Form ["username"];
Puserpwd. value = request. Form ["userpwd"];
Conn. open ();
Sqldatareader SDR = cmd. executereader (commandbehavior. closeconnection );
If (SDR. Read ())
{
Session ["userid"] = convert. tostring (SDR ["ID"]);
Session ["stuname"] = convert. tostring (SDR ["realname"]);
Session ["stunumber"] = convert. tostring (SDR ["stunumber"]);
Session ["academe"] = convert. tostring (SDR ["departmentname"]);
Session ["classname"] = convert. tostring (SDR ["classname"]);
Response. Redirect ("myorder. aspx"); // login successful
}
Else
{
Response. Redirect ("default. aspx"); // Logon Failed, incorrect username or password
}
}

After the loginfromothersite. ASPX page is processed, both websites are logged on. But I want to know where this method is not safe,
What security issues may be caused? I hope some friends can tell me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.