1

What i am trying here is to pass values to other pages. When i include the following code

private void Button1_Click(object sender, System.EventArgs e) { Response.Redirect("WebForm5.aspx?Name="+txtName.Text); } if (Request.QueryString["Name"]!= null) Response.write( Request.QueryString["Name"]); 

everything works fine the name gets displayed. Now if use MemberId instead, though i can see the Id in the Url, but while checking for Null in other page, its true i.e. if (Request.QueryString["MemberId"]!= null) Response.write( Request.QueryString["MemberId"]); doesnt gets printed. Whats wrong??

Now I tried the same thing using session i.e.

Session["MemberId"] = this.TxtEnterMemberId.Text; if (MemberSex.Equals("M")) Response.Redirect("PatientDetailsMale.aspx",false ); 

Page_load event of the other page

if (Session["MemberId"] != null) mid = Session["MemberId"].ToString(); 

IT Works..Could u guys explain the behaviour please?

P.S. Can anyone give a breif in layman words about SessionId and its usage.

Thanking you,

Indranil

1
  • You have posted only the code you get to work - What about posting the code that DON't work...? Commented May 5, 2010 at 12:41

3 Answers 3

1

if you have MemberId in the Url then it will be available by Request["MemberId "] and there is no exception to that.

please make sure you are checking for the correct name in Request["holderName"]

Sign up to request clarification or add additional context in comments.

Comments

0

Well first of all you use querystring for unimportant information. You should use a session variable if you don't want the user to see the value. The session is saved on server side!

Querystring usage:

Response.Redirect("Default.aspx?id=4"); 

After that you can read it on other page:

if (Request.QueryString.Count > 0) Int32 i = Convert.ToInt32(Request.QueryString("id")); 

Session usage:

Session["id"] = 5; 

After that you can read it on other page:

if (Session["id"] != null) Int32 i = Convert.ToInt32(Session["id"]); 

Hope this helps you

1 Comment

thanks for the explaination...but wy doesnt my code works...the first part.
0

To give you a brief explaination about Session State, by default config they are stored as live objects in the IIS worker process (called InProc), being user-isolated (one user cannot access another user's session). You can change this behavior to define the session data to be stored in other places like a SQL Server database or a State Server by using, in the configuration file, the element . Being that, webfarms have a problem with InProc session storing, so in this case SQL or StateServer can solve it.

Refer to http://msdn.microsoft.com/en-us/library/ms972429.aspx for further info.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.