What is the difference between HttpContext.Current.Application.Get([some enum]) and just enum?
I have:
HttpContext.Current.Application.Get(KeyNames.EncodedKey).ToString()
Where KeyNames
is an enum.
I can't use HttpContext
. What should I check before I just use KeyNames.EncodedKey
instead of HttpContext.Current.Application.Get(KeyNames.EncodedKey).ToString()
? (or is there another w开发者_运维问答ay?)
Thanks.
You can store data in the Application
object, just like you can store stuff in the Session
or in the ViewState
. This data is stored in a dictionary-like data structure, so you have a key as well as a value.
Now, the two things you mentioned are two fundamentally different things:
KeyNames.EncodedKey
is just an enum value.HttpContext.Current.Application.Get(KeyNames.EncodedKey).ToString()
returns the value stored in the Application object whose key isKeyNames.EncodedKey
. The value is then converted to a string.
So, just using KeyNames.EncodedKey
is in no way a replacement for HttpContext...etc.
.
Just tell us what you want to do and why you cannot use HttpContext
, then someone might be able to suggest a solution to your problem.
精彩评论