solve this session error [Resolved]

Posted by Oswaldlily under ASP.NET on 1/6/2012 | Points: 10 | Views : 1367 | Status : [Member] | Replies : 3
I have login page,home page,menu page,master page

In master page i have called username of loginpage through session..
I execute my program..ran well...

now when i called my second page directly freshly in mozilla firefox like following
localhost:12345/Folder/home.aspx ,it s pointing out session["username"] error.

My expectation: when i access second page ,it shd produce me 1st page...

how s t possible?




Responses

Posted by: Websoftcreation on: 1/7/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

First you have to ensure that what is session timeout property in web.config file is set.And at your another page or welcome page
check your session value.
public void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
if(session["username"]!=null)
{

}
else
{
response.Redirect("Login.aspx?status=login first");
}

}
}

Regards
Websoftcreation,Jaipur
(An Software development and corporate training company)

Websoftcreation
website: http://www.websoftcreation.co.in

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/6/2012 [Member] [MVP] Starter | Points: 25

Up
0
Down
hell Oswaldlily ,


Show ur code.. and error . . i try it to solve ur query . .

Best Regard's
Prabhakar

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 1/7/2012 [Member] Silver | Points: 25

Up
0
Down

While using the Session Variable check does it have null value
if(Session["UserName"]!=null)
{
//do your task
}
else
{
//go to login page
}

Thanks,
Sanjay

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response