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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:13:43+00:00 2026-05-23T16:13:43+00:00

a quick question for an ASP.NET expert. It is an arguable moment for us

  • 0

a quick question for an ASP.NET expert. It is an arguable moment for us in the company at the moment…

We have built a nice (no bugs in there) CMS framework that we use for our sites…

It goes something like this:

MyCms.Content.Channels channels = new MyCms.Content.Channels();

where at the moment of instantiating the Channels class, it loads a bunch of XML files and converts them to a List<MyCms.Content.Channels.Channel> that is held within the Channels class, and cached using System.Web.HttpRuntime.Cache (until there are any changes to the folder holding the XML files)

The Channels class is basically a hierarchical structure for web pages…

We normally use it like this in our ASP.NET pages (code behind):

public partial class Default : System.Web.UI.Page
{
    public MyCms.Content.Channels channels;
    public MyCms.Content.Images images;

    public MyCms.Content.Channels.Channel CurrentChannel;
    public List<MyCms.Content.Channels.Channel> latestItems;

    public MyCms.Content.GameVotes votes;
    public MyCms.Content.GameVotes.Vote vote;

    protected void Page_Load(object sender, EventArgs e)
    {
        channels = new MyCms.Content.Channels();
        images = new MyCms.Content.Images();
..
}

as you can see, the public variable ‘channels’ is instantiated at Page_Load()… where at the moment it has loaded a bunch of XML files either from a file system, or from cache…

Our colleague though, is sometimes instantiating this class outside of Page_Load() – right next to the public declaration of the ‘channels’ variable like this:

public partial class Default : System.Web.UI.Page
{
    public MyCms.Content.Channels channels = new MyCms.Content.Channels();

    protected void Page_Load(object sender, EventArgs e)
    {

… he does the same in various User Controls…

Now thing is.. I need your opinion on whether it’s ok to instantiate a very active class like this – outside of Page_Load() event… ? The site that was built by our colleague was hanging the entire IIS from time to time, and I just suspect that this could be one reason… – what do you think, please ? 🙂

The same CMS Framework is being used on other sites, on other servers with no issues at all… So the only difference I could find between the good working sites and the one that is hanging – is this .. instantiation of ‘channels’ class outside the scope of Page_Load()…

  • 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-23T16:13:43+00:00Added an answer on May 23, 2026 at 4:13 pm

    It shouldn’t make a difference. That’s not to say it doesn’t.

    All that’s happening is you’re changing the point at which you create the object from load event, which happens about half way through the lifecycle to the constructor, right at the very start. At both points the cache should be available as it’s part of the context, although you really ought to check that.

    I would say though, instantiating such an important class should happen at a specific point, like page initialise or load, rather than at constructor.

    Simon

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

Sidebar

Related Questions

I got a quick question, I am building an ASP.NET website and have a
OK, here is the question, I have a asp.net website, there is an aspx
quick question :) I have an ASP.NET MVC view. I want the view to
A quick ASP.Net performance question... I have an ASP.Net 3.5 SP1 Application that I
Quick question. How would you refactor this Asp.net MVC 2 HtmlHelper? Specifically would it
Quick question regarding the use of Singleton lifestyle in Windsor, and Asp.Net MVC. If
Question I'm trying to build a quick and easy ASP.NET page that redirects a
Quick question on LINQ to SQL generated queries output. I am in a ASP.NET
I have a question regarding launching an external application from an asp.net website. Now
Quick question: How do you set defaultvalue with asp? Here is my code: <SelectParameters>

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.