Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
if (!object.Equals(Session["Id"], null))
{
    if (Object.Equals(Session["Id"],Request.QueryString["Id"].ToString()))
    {
        lblError.Text = "Your own profile";
        lblError.Visible = true;
    }


what this code do?

Dif between Session["Id"] and Request.QueryString["Id"]

what is Object?
Posted
Comments
Kim Togo 15-May-11 3:49am    
Is it yours project or are you working on a project that some one has written?
You ask all the time:
"Info about that code..."
"I want info about the code.."
"Error in code..."
"I want some info..."
"Error in handling the image..."
"Error in code plz check and plz explain the code"
"Answer the question.."
"Code is working please check."
"Plz check the code.."

Try use Google or Bing for your search and try learn what the code do. Try use debugger, try... etc.

Request.QueryString["Id"] is the same as Request["Id"]. This can be seen on your query string (ex. http://yoursite/yourDir/yourpage.aspx?Id=3)

While the session is more like a storage available only on your active browser when the session was initiated.

Info about the code :

1. It performs a check if the Session is id named "Id" is not null.
if (!object.Equals(Session["Id"], null))


2. The condition is set that it will return true if the string saved on the Session["Id"] is equal to the querystring sent on the page.
if (Object.Equals(Session["Id"],Request.QueryString["Id"].ToString()))


3. The main purpose of that code is to check if the current id passed on that page is the same id the user used to login. That way, the system can prevent usage of the page by editing the query param Id with different id besides yours.

3. Code was done by a baby programmer.
 
Share this answer
 
Object is the base class of every single entity in .NET

Every single thing you declare, create, or instantiate is based in the end on Object.

As for the rest of your question:

Stop asking "please explain this code" and go and find a book. Read it. Follow it. Do the examples and exercises. You will learn a whole lot more about what the heck is going on than you will by asking us to explain every single new thing as you come across it.

Oh, and learn to use Google while you are at it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900