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 8283175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:38:44+00:00 2026-06-08T10:38:44+00:00

I have a site which uses a C# class file, and at the top

  • 0

I have a site which uses a C# class file, and at the top of the file, I have:

JTSEntities database = new JTSEntities(); (an ADO.NET thingy).

I have it right up the top because I don’t really feel like writing the same thing over and over again.

But it raises one question… Because it’s up the top there, how will it get disposed, and when – and how can I dispose of it (or do I need to) when the user closes the page?

  • 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-06-08T10:38:45+00:00Added an answer on June 8, 2026 at 10:38 am

    Ok so, based on the type of the attribute, we can say that it’s an instance attribute. This means that this attribute will have the same lifecyle as the object that has it, unless its instance is passed to another object.

    If it’s protected, then only the owner object and its childs (that is, objects that inherit from this class) will have access to it. If you don’t pass it as a reference argument, then we’re ok with the first statement: it will be cleaned by the GC as soon as the object is cleaned.

    If you just use this object on a regular webform page lifecycle, then you don’t have to worry with disposing it. The page lifecycle will do it for you.

    Regards

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

Sidebar

Related Questions

simple question... Given I have an ASP.NET site, which uses a [custom] RoleProvider, Is
I have a web site which uses one SQL database but the hosting company
I have site which uses $(selector).load(path) function in more than 300 pages. Now my
I currently have a site which uses a MySQL 4.x schema, the site uses
I have a navigation on a site which uses subnavigation in the main navigation...
I have my site mydomain.local on my local development machine, which uses a local
I have a window application which uses SP classes to create a site. I
I have a site that uses a menu control tied to a sitemapdatasource which
I have a site that uses a large centered background image, which naturally loads
I have a web app which uses Devise for authentication. It is a site

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.