开发者

What is the difference between HttpContext.Current.Application.Get([some enum]) and just enum?

开发者 https://www.devze.com 2023-01-20 12:19 出处:网络
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 o

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 is KeyNames.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.

0

精彩评论

暂无评论...
验证码 换一张
取 消