Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Response.Redirect("~/UserDetails.aspx?Id=" + Session["Id"].ToString());
What this line do?
 
What Is Id?
Posted 22-Jun-11 0:04am
Edited 22-Jun-11 0:49am
thatraja242.7K
v2
Comments
S Mewara at 23-Jun-11 5:00am
   
Dude you need to pick a book and read instead of posting code and asking about each and every line!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Id is the querystring parameter, This will be redirected to the next page and the id value can be used as the parameter.
See http://en.wikipedia.org/wiki/Query_string[^] for more information on query strings.
  Permalink  
Comments
Dylan Morley at 22-Jun-11 5:08am
   
lol, same link
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It's saying redirect to the UserDetails page and pass in a query string [^] with a name of 'Id' and the value is retrieved from the Session.
 

Basically, when the UserDetails page loads, it will be able to retrieve the Id passed to it and load up the User that matches the Id.
  Permalink  
Comments
Abhinav S at 22-Jun-11 5:11am
   
Same link. So my vote of 5. :)
Dalek Dave at 23-Jun-11 3:39am
   
Spot on!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

1. The Redirect method causes the browser to redirect the client to a different URL.
 
2. In short anything after ? will be categorized into query string as name and value. There can be multiple query string. In this case ID is the first one.
 
for detailed understanding of URL you can go through URL Specification[^]
  Permalink  
Comments
Dalek Dave at 23-Jun-11 3:39am
   
Yep!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

As others have explained, ID in this case refers to the Session variable, and to the query string. Now, you may be asking yourself why the user would need to pass the variable across - after all, you already have it in the session, so the page being redirected to (which belongs to the same site) should be able to pick that up.
 
The answer is because a session is volatile. In other words, you have no guarantee that the session will continue to be there when the redirect completes. This is a fairly naive piece of code, because it also assumes that the session value is there when the call is issued - there's no guarantee that this is true; if a page has been left sitting unattended for a long period of time, the session could well have been recycled.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hi
 
Starting First Stage:- Session["Id"].ToString());
 
This is using for maintain session in your application.
 
Firstly you check where id exists as paramerter in your application
 
Like ID=10;
 
session["id"]=id;
now session[10]
 
Response.Redirect("~/UserDetails.aspx?Id=" + Session["Id"].ToString());
 
on your explorer you see "userdetails.aspx?id=10"
 
this is basically used for one page value send to another page...
 
Thanks
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 23 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100