Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6060093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:47:09+00:00 2026-05-23T08:47:09+00:00

I am keeping an global object in application cache, retrieving and modifying it based

  • 0

I am keeping an global object in application cache, retrieving and modifying it based on my needs. The weird thing is once I modify the retrieved object the application object is getting modified too. I don’t want the application object to be modified.

System.Web.HttpContext.Current.Application["obj2"]=obj2;

like

object obj1 = System.Web.HttpContext.Current.Application["obj2"];

when I modify obj1 the obj2 is getting modified too. Can you guys suggest me the solution for the above problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:47:10+00:00Added an answer on May 23, 2026 at 8:47 am

    Objects in C# are always by-reference, which means that whenever you access this object it will always be the same instance to the object. It sounds like what you might want to do is to clone it first then modify the clone instead. This is also important for shared memory multi-threaded environments like what you have above.

    Also, you might consider making the object that you are caching a struct, which is passed by-value instead of by-reference, as long as you unbox it first. In general you don’t want to edit objects shared by threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Keeping the GUI responsive while the application does some CPU-heavy processing is one of
What is the best practice on setting and keeping these global objects ? I
Keeping performance on a mobile device in mind, what do you think is the
Is keeping JMS connections / sessions / consumer always open a bad practice? Code
I'm curious about keeping source code around reliably and securely for several years. From
( Almost exact duplicate of Keeping original format POST passing through AWK submitted by
Are primitives worth keeping? Should all the deprecated stuff be deleted? Do we need
What are the advantages/disadvantages of keeping SQL in your C# source code or in
I have a habit of keeping my variable usage to a bare minimum. So
Was looking to get peoples thoughts on keeping a Lucene index up to date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.