[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2004-11-29
Medium Priority
Last Modified: 2008-03-17
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"?
Question by:Finch

Accepted Solution

gadget27 earned 800 total points
ID: 12699638
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.
LVL 21

Assisted Solution

surajguptha earned 200 total points
ID: 12702964
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;

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Integration Management Part 2
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question