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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:02:37+00:00 2026-05-23T03:02:37+00:00

I know that controllers are supposed to handle every action but how do I

  • 0

I know that controllers are supposed to handle every action but how do I preprocess some requests in asp .net mvc? For example there are a lot of things that are required in all my controllers. Coding this in each controller isn’t quite right so I need to save some data in the http context session so that I can access it in every controller.

And if I store the objects in the session I also need to somehow properly dispose or make available for later use some objects in the httpcontext session? In my case, I use nhibernate to map my objects to a database and I was thinking of creating a pool where to store my ISession instances,sessions or connections with my database, and make them available as required. I don’t know if it’s okay like this but it’s the best idea I came up with rather than creating those ISession everytime.

I’m pretty new to this so I probably use a lot of these things not so well.

  • 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-23T03:02:38+00:00Added an answer on May 23, 2026 at 3:02 am

    Override the MvcHandler class and implement your logic there. Then override the MvcRouteHandler to provide your custom IHttpHandler implementation instead of the default MvcHandler. This will be easier to do if you look at the source of these classes and understand exactly what is happening in between ASP.NET receiving the request and the controller executing.

    Another option is to create a BaseController that handles all the preprocessing, and derive any controllers in the solution from the base controller. This would work, but it doesn’t seem as appropriate for what you are trying to do as the first solution I suggested.

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

Sidebar

Related Questions

lets say i have two view controllers, firstViewController and secondViewController. The firstViewController is supposed
I have a problem with the understanding MVC architecture. It's not that I don't
I find a common issue in my RESTful Rails apps controllers that respond to
My application I have an application design that looks like this: web application layer
i'm trying to check whether my forms(Zend_Form) are being well processed and display whatever
def mock_category(stubs={}) @mock_category ||= mock_model(Category, stubs).as_null_object end describe GET show do it assigns the
Long post.. sorry I've been reading up on this and tried back and forth
I'm trying to build my first app on CodeIgniter. This is also my first
I'm trying to build my first app on CodeIgniter. This is also my first
I'm struggling with paperclip and adding the attached images to albums. Should I be

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.