"How do I build a string in HTML that includes the current "SessionID"?

I am building a website using ASP.net.   I now know how to build a string in the code-behind (C#) that includes the current "SessionID", it works like this:

String strSecureURL = "https://www.MySite.com" + this.Request.ServerVariables["SERVER_NAME"].ToString() + "/(" + this.Request.ServerVariables["HTTP_ASPFILTERSESSIONID"].ToString() + ")" + this.Request.ServerVariables["URL"].ToString();

My question is "how can I build a similar string in the HTML code?".  In other words, "How do I build a string in HTML of the form "href=https://www.MySite.com/pathname/(sessionID)/pageXX.aspx"?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I am not sure if I understand this question correctly, but if when you say 'in HTML of the form' you mean in the the HTML of the ASPX file for that form, you can simply insert your code in the ASPX file surrounded by <% and %>.


String strSecureURL
strSecureURL = "https://www.MySite.com" + this.Request.ServerVariables["SERVER_NAME"].ToString() + "/(" + this.Request.ServerVariables["HTTP_ASPFILTERSESSIONID"].ToString() + ")" + this.Request.ServerVariables["URL"].ToString();

Then in your anchor tag....

<a href='<%=strSecureURL%>'>

That ought to do it for you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You can build a string using javascript or VBscript. But using javascript or VB script we wont be able to access server variables. So it would require us to save these values in hidden variables.

Assuming that the three values are stored in h1,h2,h3 and we are using javascript.

function BuildString()
    var strUrl = 'https://www.MySite.com' + document.all.h1.value + "/(" + document.all.h2.value + "/("  + document.all.h3.value;
return strUrl;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.