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

  • Home
  • SEARCH
  • 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 3338738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:24:41+00:00 2026-05-18T00:24:41+00:00

I am overriding the Controller.Dispose(bool) method in my ASP.NET MVC2 Controllers in order to

  • 0

I am overriding the Controller.Dispose(bool) method in my ASP.NET MVC2 Controllers in order to dispose of things as needed, while leaving them alive for as long as possible. This is as opposed to disposing of them prior to returning from the Controller’s action method.

My question, in short; does this work as I expect?

From what I’m seeing so far, this seems to provide exactly what I need; all IDisposable objects are getting disposed (The Controller.Dispose() method calls the virtual Controller.Dispose(bool)), but not until they are no longer needed.


EDIT #2:

I appreciate the advice on what I should be doing. I mean that; I up-voted just such an answer, in fact.

For the purposes of this question, though, let’s assume that I have evaluated my own needs and have decided that calling an occasional related-entity-property in my View works best for me, and that I have decided that I am not really in need of a Dependency Injection framework just to make sure my objects are disposed of properly.

What I really just need to know for right now is if anyone is aware of lifetime-related issues to disposing of these objects in an overridden Controller.Dispose(bool) method.

  • 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-18T00:24:41+00:00Added an answer on May 18, 2026 at 12:24 am

    +1 and thanks for this question. I can’t give you an answer based on my own experience, but I did find this post by Stephen Walter describing exactly your situation (I believe), and a comment by @Craig Stuntz suggesting the same pattern you describe. Sounds like you are good here 🙂

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

Sidebar

Related Questions

In my ASP.NET MVC app, I'm handling errors by overriding OnException in the controller.
This question is specifically related to overriding the equals() method for objects with a
What's difference between shadowing and overriding a method in C#?
UPDATED: I'm now overriding the NSView keyUp method from a NSView subclass set to
When overriding the MembershipProvider and calling it directly, is there a way to fill
When overriding the equals() function of java.lang.Object, the javadocs suggest that, it is generally
I'm overriding WndProc, so I want to write code like if (m.Msg == WM_COMMAND)
I am overriding a Grid, adding some customer features. One of the features is
I was wondering whether overriding conversion operators is only applicable to numeric types? If
What issues / pitfalls must be considered when overriding equals and hashCode ?

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.