|
查看: 1461|回复: 15
|
aspx.net login + security 问题
[复制链接]
|
|
|
我弄了login function,然后才能link到pageA。但是我直接copy pageA 的link, 放在web browser 就可以 link 到了,而不用login了。
要怎么弄 当我直接按 link 的时候还要 login? |
|
|
|
|
|
|
|
|
|
|
发表于 11-11-2010 08:32 PM
|
显示全部楼层
login page 的button event加入
strEmail = txtEmail.Text.Trim
strPassword = objCodeFunction.Password_Encrypt(txtPassword.Text.Trim)
dsData = New DataSet
dsData = objAccount.Login(strEmail, strPassword)
If dsData.Tables(0).Rows.Count > 0 Then
Session("rpaccount") = dsData.Tables(0).Rows(0)("uniqueid")
Response.Cookies("rpaccount").Value = "true"
Response.Redirect("home.aspx", False)
Else
ltrMessage.Text = "Login Failed."
End If
然后每一面加上, 或者用Master Page比较容易
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache)
If Session("rpaccount") Is Nothing Or Request.Cookies("rpaccount") Is Nothing Then
Session.Abandon()
Response.Redirect("default.aspx")
End If
End Sub |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 12-11-2010 05:01 PM
|
显示全部楼层
好的~谢谢~ |
|
|
|
|
|
|
|
|
|
|
发表于 15-11-2010 05:57 AM
|
显示全部楼层
login page 的button event加入
strEmail = txtEmail.Text.Trim
strPassword = objCodeFunction.Password ...
鹿其 发表于 11-11-2010 08:32 PM 
高手咧. 会C#吗?来我公司我请你. 薪金要多少? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 16-11-2010 11:54 AM
|
显示全部楼层
用 c# translator 就可以变去 c#了~ |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 18-11-2010 04:14 PM
|
显示全部楼层
strpassword = objCodeFunction.Password_Encrypt(LoginPW2.Text.Trim)
and
objAccount.Login(strEmail, strPassword)
是function来?做么error的? |
|
|
|
|
|
|
|
|
|
|
发表于 18-11-2010 06:01 PM
|
显示全部楼层
应该是 Business Logical Layer 的Method吧.
objCodeFunction.Password_Encrypt(LoginPW2.Text.Trim) <----把输入的password Convert 成 Encrypt version.
objAccount.Login(strEmail, strPassword) <-----把Email和Encrypt password pass到 Login Method 来Call Data. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 18-11-2010 06:09 PM
|
显示全部楼层
|
但是在 aspx.net , objcodefunction and objaccount 都是error的? 需要加些code? |
|
|
|
|
|
|
|
|
|
|
发表于 18-11-2010 06:16 PM
|
显示全部楼层
|
it is a Class developed by the developer. |
|
|
|
|
|
|
|
|
|
|
发表于 18-11-2010 06:27 PM
|
显示全部楼层
本帖最后由 Reader 于 18-11-2010 06:29 PM 编辑
example:
Codefunction.cs
public class Codefunction
{
Public String Password_Encrypt(String RawPassword)
{
String EncryptedPassword;
// Code to Encrypt Password Store in EncryptedPassword
return EncryptedPassword;
}
}
----------------------------------------
button event page
Codefunction objCodeFunction= new Codefunction ();
strpassword = objCodeFunction.Password_Encrypt(LoginPW2.Text.Trim); |
|
|
|
|
|
|
|
|
|
|
发表于 19-11-2010 06:13 PM
|
显示全部楼层
但是在 aspx.net , objcodefunction and objaccount 都是error的? 需要加些code?
pσtεtσ-ζх 发表于 18-11-2010 06:09 PM 
Create 一个Class name it CodeFunction.cs
-
- public class CodeFunction
- {
- public String Password_Encrypt(String RawPassword)
- {
- //MD5 the input text
- MD5 md5 = MD5.Create();
- byte[] data = md5.ComputeHash(Encoding.Default.GetBytes(RawPassword));
- StringBuilder sBuilder = new StringBuilder();
- for (int i = 0; i < data.Length; i++)
- {
- sBuilder.Append(data[i].ToString("X2"));
- }
- return sBuilder.ToString();
- }
- }
复制代码
Button Event 的 Code
- protected void Button1_Click(object sender, EventArgs e)
- {
- CodeFunction objCodeFunction = new CodeFunction();
- Label1.Text= objCodeFunction.Password_Encrypt(txtpassword.Text.Trim());
- }
复制代码
objAccount.Login(strEmail, strPassword) 是另一个Class 的 Login Method Connect to Database Return Dataset. |
|
|
|
|
|
|
|
|
|
|
发表于 1-12-2010 01:24 PM
|
显示全部楼层
回复 4# robertino
C#有学过, 不过过后专攻vb.net.vb.net可以apply吗? |
|
|
|
|
|
|
|
|
|
|
发表于 1-12-2010 01:28 PM
|
显示全部楼层
|
是的, 那是我自己的class. 有兴趣的话, PM我你的email, 我email给你. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 2-12-2010 01:35 AM
|
显示全部楼层
回复 13# 鹿其
我要可以吗?poteto_jx@yahoo.com
谢谢大大~ |
|
|
|
|
|
|
|
|
|
|
发表于 3-12-2010 04:26 PM
|
显示全部楼层
回复 14# pσtεtσ-ζх
email给你了. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 6-12-2010 02:24 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|