How to redirect to login page if not logged in
hi
i am developing a website in c#
my web site has a menu in which some items redirect to pages which contains private data so i want to restrict those pages to redirect to login page if the user has not been logged in to yet if he is logged in those items redirect to the page which it has to actually
can any body help me
Vimal KandasamyPosted May 1, 2009, 3:08 AM
Its depending upon storing user logged info.
Ex:
If you store user info in Sessions while logging.
Like below
Session["uname"] = username.Text
then you can check it at the time of redirecting to private pages by getting its value using
Session["uname"].ToString();
if user not yet logged in and you didn't store username value in Session,then it contains null or its throw NullReferenceException then you can restrict user and redirect to login page.