hi every one,
i developed the web application in ASP.Net
there i want make an authentication security
so, the problem is when i copy the URL address in one web form and paste into another web form ,that time the login page will be showed automatically
can anybody give the suggestion and source code
I think this problem will be solved by the use of session state
regards,
vijay
Loading
Kirtan PatelPosted Aug 5, 2009, 2:02 AM
Session["Username"] = textBox1.Text;
Session["Password"] = textBox2.Text;
// Retrieve Using This Code at Any Form Using Code Below
string Username = (string)(Session["Username"]);
string Username = (string)(Session["Password"]);
Happy Coding :)
Niradhip ChakrabortyPosted Aug 5, 2009, 1:59 AM
vijay antonyPosted Aug 5, 2009, 1:50 AM
thanks for replying
in my login page i have division ,username,password
i declared the session as session[username]=Textbox1.text
but it shows error like declaration expected
so how to declare session for these three items
and how to get these values to all forms
regards
vijay
Niradhip ChakrabortyPosted Aug 3, 2009, 3:31 AM
Like. after successful login validation and before redirecting to next page create a session.
In my login page inside submit button I am validating user for username and password
and if validation is sucessful i am redirecting it to next page. Now before redirecting I am assigning a session value like this.
Session["islogIn"] = 1;
Now in all the pages which come after successful login validation add this code in page load.
protected void Page_Load(object sender, EventArgs e)
{
if ((Session["islogIn"] == null) || (Session["islogIn"]== ""))
{
Response.Redirect("../Login.aspx");
}
}
Note: Make sure after logout you should make the session empty.Like below.
Session["islogIn"] ="";
Explaination: So the session having value only if someone sucessfully login from login page. If some one just copies the URL in browser for other pages, that time session doesnot have any values and it will redirect to login page.