On Mar 12, 2:42 pm, "Control Freq" <
[email protected]>
wrote:
Yes, I was referring to Session["SomeName"] = "XYZ".
I wasn't specifically meaning the style of writing the Session
Variable name, i.e using camel casing or pascal casing.
I was really wanting to know if the variable name had the Application
name, and page name embedded in it. I understand that large web apps
might use a lot of session variables, so is it a good idea to separate
them using something like "OrderEntry_DespatchDate", or
"CustomerEntry_ContactName", using the first words to specify which
screen the variable is used?
Otr, is there a better way of doing this sort of thing?
I think that putting the page name as part of the variable name could
cause maintenance problems in the future (or at the very least code
smells). And what happens when a variable is referenced across pages
(which is part of reason for using them)?
I suppose you could use your full namespace:
Session["MyCompany.MyApp.XYZ"], but again once you start putting stuff
like this in strings you're asking for maintenance troubles.
Here's what I tend to do:
- use the same naming convention as for classes (i.e. pascal
notation), and just use a sensible, meaningful name (just pretend
you're naming a function and you won't go far wrong).
- use a base class for my pages, and wrap session variables into a
strongly-typed property in the base class. I can provide an example if
you like.
HTH
JC