In Global.asax i have:
void Application_Start(object sender, EventArgs e)
{
//Key is Login name and value is password
Application["dan"] = "123";
Application["rafi"] = "123";
Application["nick"] = "123";
Application["dave"] = "123";
}
Now i have login.aspx page where i need to check login and password that is in application state. I have two textboxes and button. I need to check if value typed in texboxUserName.text exists in application state, values needed to be -dan, rafi, nick or dave. how do i do that?:) It's an exercise in our school..
UPD Ok i did it:) thx for help
protected void btnLogin_Click(object sender, EventArgs e) {
string name=txtUserName.Text;
string pass = txtPassword.Text;
foreach (string key in Application.AllKeys)
{
if (key == name)
{
string curectName = name;
if ((string) Application[curectName] == pass)
{
Response.Redirect("~/Default.aspx");
}
else
{
lblError.Text = "pass don't match";
}
}
else
{
lblError.Text = "no name";
}
}