1
votes

I have seen many articles about session bridging between Classic ASP and ASP.Net. But, I could not find one that works not only saving primitive types to session state and but also saving reference types to the session state.

I want to know how array can be saved to classic ASP session and retrieved from ASP.Net session vice versa.

I know this is not easy as things like marshaling and serialization will be brought into the topic. But I want to make a guess about how far I need to go to achieve this.

1
You can manually "serialize" the array to a string then make it back to array in the receiving side. - Shadow Wizard Is Vaccinated V3
@ShadowWizard The problem is that I could not find a way to serialize array in classic asp.(I have been seeing many articles.) What is more, I think even array that is serialized from the classic ASP cannot be retrieved from ASP.Net due to the fact the memory allocation is not the same.(my two cents). It would be really helpful if you can provide me a reference or a short explanation of manual serialization. Thanks for the attention. - Pyae Phyo Aung
I didn't mean serialization as we know it in ASP.NET just simple "manual" conversion of array to string and back; see my answer. :) - Shadow Wizard Is Vaccinated V3

1 Answers

2
votes

You can always make your own serialization of plain arrays: in classic ASP convert them to a string using a delimeter then parse the string back to array in the ASP.NET code.

Both offers you simple methods out of the box: Split() and Join(), so in classic ASP:

myArray = Array("Jon", "Bob", "Don")
Session("SerializedArray") = Join(myArray, "|")

Then in the ASP.NET when reading it:

string[] myArray = (Session["SerializedArray"] + "").Split('|');