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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:27:00+00:00 2026-06-16T13:27:00+00:00

Possible Duplicate: What is the ‘page lifecycle’ of an ASP.NET MVC page, compared to

  • 0

Possible Duplicate:
What is the ‘page lifecycle’ of an ASP.NET MVC page, compared to ASP.NET WebForms?

In ASP.NET MVC, I cannot find anything in the numerous “page lifecycle” or “request lifecycle” articles I’ve read that touches on object disposal. In an action method, if I create a connection to a database (or maybe create a context to EF), does it ever get disposed if I don’t explicitly called dispose?

I know that the model binding to the view can require an open connection still (especially if it’s serving an EF object with associations) but does it then dispose of everything instantiated during the request? If so, can someone point this documented out to me please?

  • 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-16T13:27:01+00:00Added an answer on June 16, 2026 at 1:27 pm

    A new instance to the controller object is created for every request. This means that the reference to this controller is lost once the action is performed. There on it is left to the garbage collector to dispose and close all the resource intense objects.

    So, the best practice is always to close and dispose all the heavy duty objects in the action method itself.

    I understand that the view would require live connections when binding EF objects. Again the best practice here is to enumerate them before binding to the view.

    The answer to your question is – The garbage collector will be responsible for disposing or closing the connection that are left open in action method – And this is a formula for disaster.

    EDIT
    Note: Controller class implements IDisposable, so it should be disposed after the request is served. However when I checked the source code of DefaultControllerFactory, I couldnt figure any using scope or explicit dispose call.

    reference

    http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/5d4159c85ff6#src/System.Web.Mvc/DefaultControllerFactory.cs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What is the ‘page lifecycle’ of an ASP.NET WebForm? when i am
Possible Duplicate: Asp.net MVC page is giving Mime type warnings for image files I
Possible Duplicate: What is the 'page lifecycle' of an ASP.NET WebForm? I have studied
Possible Duplicate: Get URL of ASP.Net Page in code-behind I'm trying to hold current
Possible Duplicate: Multiple forms on ASP.NET page i have a doubt. can we place
Possible Duplicate: Conditional Logic in ASP.net page I am new to ASP.NET. Lets say
Possible Duplicate: ASP.NET postback with JavaScript I have a page without a form. But
Possible Duplicate: How to read parameter passed from asp.net page, using C#? I want
Possible Duplicate: Meaning of the various symbols in .aspx page of asp.net I'm familiar
Possible Duplicate: Asp.net how to correct the error I'm designing my web page using

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.