开发者

How to pass session id from one page to another in ASP.Net

开发者 https://www.devze.com 2022-12-21 07:31 出处:网络
Response.Redirect(\"Password_ret.aspx?userid=\"+TextBox1.Text); sends the data present in the text box to password_ret page
Response.Redirect("Password_ret.aspx?userid="+TextBox1.Text);

sends the data present in the text box to password_ret page

Similarly, What command should I use for

protected void GridView1开发者_高级运维_SelectedIndexChanged(object sender, EventArgs e)

to send the data to the next page. I am using

Response.Redirect("Feedback.aspx?Session_ID=" ??what should be used here??);

Session_ID is a field in my database


I would suggest storing the session ID in a cookie


To store session information you can use the Session object, a Cookie, ViewState, the QueryString or a Hidden Form variable. A quick search on StackOverflow or Google should help you decide which is the best option to suit your needs.


Do you want the .NET Session ID?

It's available in the field:

Session.SessionID

If that's what you're after. If you want Session ID's to be passed in the URL instead of using cookies, you may enable it like so, in the web.config:

<sessionstate 
  mode="inproc"
  cookieless="true" 
  timeout="20" 
 />


Add

DateKeyNames="SessionID"

to your GridView declaration.

Then in your code behind:

Response.Redirect("Feedback.aspx?Session_ID=" + GridView1.SelectedValue);
0

精彩评论

暂无评论...
验证码 换一张
取 消