tags:

views:

36

answers:

1

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 way?)

Thanks.

+1  A: 

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.

Heinzi