i have created a webpage. i want that before entering in that page session should check that what is the role of user that is admin or user. i have put the following condition.
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Role"].ToString = "User")
{
Response.Redirect("Dataentry.aspx");
}
else
Response.Redirect("ControlPannel.aspx");
}
But it gives me the following error:
The name 'Session' does not exist in the current context
i have also used Session("Role") but gives the same error.
please tell me what is the problem.
Loading

Sandeep ShekhawatRank #2,439 · 577 reputationPosted Jun 24, 2011, 2:56 AM EDT
protected void Page_Load(object sender, EventArgs e)
{
string Role=Session["Role"].ToString();
if (Role = "User")
{
Response.Redirect("Dataentry.aspx");
}
Sandeep ShekhawatRank #2,439 · 577 reputationPosted Jun 24, 2011, 2:31 AM EDT
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Role"].ToString() = "User")
{
Response.Redirect("Dataentry.aspx");
}
saifullah khanRank #4,887 · 320 reputationPosted Jun 24, 2011, 2:35 AM EDT
The left-hand side of an assignment must be a variable, property or indexer
saifullah khanRank #4,887 · 320 reputationPosted Jun 24, 2011, 2:52 AM EDT
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;