Search code examples
asp.neturlhttp-redirecthyperlinksession-variables

Passing a Session Variable via a URL (ASP.Net)


I have an aspx page, which is a "User Log-In" area. I want to pass the userid to another page which is linked from the aspx page.

the link I have looks something like this:

www.abcdefg.com/Home/Redirect/?authtkn=123456abcd=xxxx

I need the xxxx to be a session variable which in this case is userid.

**userid is not sensative information, this is simply to redirect the user to another page for specified information.

Any thoughts on how to pass a session variable to a URL, or if this can be done. The example www.abcdefg.com is a different domain (on a different server) from the original aspx page.


Solution

  • Why not appending like this?

    string.Format("www.abcdefg.com/Home/Redirect/?authtkn=123456abcd={0}", 
        Session["UserId"]);
    

    if i understood you correctly.