I wrote a composite web control that is used in several web applications. If I use sessions variables, for example HttpContext.Current.Session("MyProgramMemberId"), do I run the risk that the host site might have also defined that same session key name?
I’d like to hear of your experiences if you had a problem with this. It would be a bonus if you have website reference that you trust.
Thanks!
I can’t say that I have any actual experience with this (mainly because I wouldn’t do this), but yes it’s absolutely possible that you could have a collision with another session variable named the same thing in the hosting web application.
What I would suggest is removing the reliance on the session variable, and instead use a ViewState variable instead. These are more isolated to specific instances of your control, and therefore should not conflict with each other. Of course there are considerations based on what you need to store, you would want to be careful trying to store large objects, lists, dictionaries, as well as sensitive information in the viewstate (which ends up being transmitted to the client). But based on your sample code, it looks like it’s a simple Id property which is small and (usually) not sensitive.