session problem
-
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["mysession"].ToString() != null) { Label1.Text = "Welcome " ; } else { Response.Redirect("Login.aspx"); } } } I have the above code in one aspx page. Before logging in if someone opens this page, it should open Login page. But instead of showing theLogin page, it shows Server Error. Any one have an idea.
-
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["mysession"].ToString() != null) { Label1.Text = "Welcome " ; } else { Response.Redirect("Login.aspx"); } } } I have the above code in one aspx page. Before logging in if someone opens this page, it should open Login page. But instead of showing theLogin page, it shows Server Error. Any one have an idea.
What error are you getting in the page ? Could you clarify that
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["mysession"].ToString() != null) { Label1.Text = "Welcome " ; } else { Response.Redirect("Login.aspx"); } } } I have the above code in one aspx page. Before logging in if someone opens this page, it should open Login page. But instead of showing theLogin page, it shows Server Error. Any one have an idea.
Soumini Ramakrishnan wrote:
if (Session["mysession"].ToString() != null)
This is wrong. It should be
if (Session["mysession"] != null)
{
Label1.Text = "Welcome " ;
}
else
{
Response.Redirect("Login.aspx");
}When session is
null
, you can't invoke it'sToString()
method.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["mysession"].ToString() != null) { Label1.Text = "Welcome " ; } else { Response.Redirect("Login.aspx"); } } } I have the above code in one aspx page. Before logging in if someone opens this page, it should open Login page. But instead of showing theLogin page, it shows Server Error. Any one have an idea.
Hi, I had made some changes in yr code, just see below. Try this code, i hope u can not get an error...
if (!IsPostBack)
{
if (Session["mysession"] != null)
{
Label1.Text = "Welcome ";
}
else
{
Label1.Text = "test";
}
}i hope it will help u..
Rana Krishnraj
modified on Wednesday, April 2, 2008 9:30 AM
-
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["mysession"].ToString() != null) { Label1.Text = "Welcome " ; } else { Response.Redirect("Login.aspx"); } } } I have the above code in one aspx page. Before logging in if someone opens this page, it should open Login page. But instead of showing theLogin page, it shows Server Error. Any one have an idea.
Thank you all. The given hints helped me and I rectified my problem.