Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session.Contents.Remove["xx"]

Status
Not open for further replies.

tester321

Programmer
Mar 13, 2007
150
CA
I'm not sure i getting error for:
Session.Contents.Remove["xx"]

-Only assignment, call, increment, decrement, and new object expressions can be used as a statement

-Cannot apply indexing with [] to an expression of type 'method group'

How does one remove the contents of 1 session when , say, 5 are valid?

Thanks
 
forgot, what i'm trying to do is: set Session["xx"] = to a var temp1, then work with that var instead of having to call session all the time, If the session or temp1 value is greater than 0, then check if it is greater than 5, if so redirect. If session is between 1 and 5 then add 1 to the temp1 value and set the Session["xx"] to this value. If Session["xx"] has no value then set it to 0.
Code:
protected void Page_Load(object sender, EventArgs e)
{
   temp1 = Session["xx"];
    if (temp1 > 0)
    {
        if (temp1 > 5)
        {
        response.redirect("");
        }
        else
        {
            temp1 = (temp1 + 1);
            Session["xx"] = temp1;
        }
    }
    else
    {
        Session["xx"] = 0;
    }

.....
another if statement...
Remove.Session.Contents["xx"]
....
}
 
change:
temp1 = Session["xx"];
to
int temp1 = (int)Session["xx"];

still doesn't like:
Remove.Session.Contents["xx"]

any suggestions? Thanks
 
I resolved this:

Remove.Session.Contents["xx"] needed to be:
Remove.Session.Contents("xx")

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top