2 Replies - 3213 Views - Last Post: 18 February 2013 - 11:14 PM Rate Topic: -----

#1 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,507
  • Joined: 16-March 11

Application.Add

Posted 18 February 2013 - 08:11 PM

Hey there fellas,

I was wondering if adding a object to the application pool under the same name and value would just overwrite the last one?

Example:
Dim k as New Table
Application.Add("k", k)



If I did that over and over would it overwrite the value already there?

Any information is appreciated, thank you.
Is This A Good Question/Topic? 0
  • +

Replies To: Application.Add

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 445
  • View blog
  • Posts: 1,501
  • Joined: 28-April 09

Re: Application.Add

Posted 18 February 2013 - 10:45 PM

I can't recall right off hand if Adding a key that already exists would throw an exception or not. Either way I would probably do something like:

if (Application["key"] == null)
{
    Application.Add("key", InitialValue);
}
else
{
    Application.Set("key", SomeNewValue);
}



This is in C# but should be pretty easy to convert to VB.

For more information on the HttpApplicationState class: MSDN

And here are some Application State Recommendations directly from MSDN as well:
(It's about 2/3rds of the way down the page if you follow the link. I copied the part about application state in the spoiler below)

Spoiler

This post has been edited by Nakor: 18 February 2013 - 10:56 PM

Was This Post Helpful? 1
  • +
  • -

#3 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,507
  • Joined: 16-March 11

Re: Application.Add

Posted 18 February 2013 - 11:14 PM

Thanks for the info. I've got a few routines similar to what you've written and one that also just continues to add the same value and key with no exceptions occurring. Thanks for clearing things up though.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1