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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:19:49+00:00 2026-06-07T23:19:49+00:00

My MVC application currently uses the Global.asax , Application_Start method to load tons of

  • 0

My MVC application currently uses the Global.asax, Application_Start method to load tons of data, and then exposes it as collections. For example:

Current Usage Example:

// Global.asax 
public static DataRepository Repository { get; set; }
protected void Application_Start()
    {
        // All the normal stuff...

        // Preload this repository.
        DataRepository = new DataRepository();
    }

// HomeController.cs Example
public ActionResult Index(){
    return Json(MyApplication.Repository.GetSomeCollection(), 
                JsonRequestBehavior.AllowGet);
}

What I’m trying to do:

I want to use the ASP.Net 4.0 + IIS 7.5 Application Preload functionality, but need to expose the repository to the rest of the application. Something like:

// pseudo code attempt at goal 

public class ApplicationPreload : IProcessHostPreloadClient
{
    public MyRepositoryClass Repository { get; set; }

    public void Preload(string[] parameters)
    {
        // repository class's constructor talks to DB and does other crap.
        Repository = new MyRepositoryClass();
    }
}

Question

How can I expose a repository class or even a simple IEnumerable<T> collection using the Preload() method implemented via IProcessHostPreloadClient?

  • 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-07T23:19:51+00:00Added an answer on June 7, 2026 at 11:19 pm

    If you’re just aiming to expose an IEnumerable<T> try stuffing it into HttpRuntime.Cache from the implementation of IProcessHostPreloadClient. You can then optionally expose the collection from the Global.asax application class.

    Something like:

    public class ApplicationPreload : IProcessHostPreloadClient
    {
        public void Preload(string[] parameters)
        {
            var repository = new MyRepositoryClass();
            HttpRuntime.Cache.Insert(
                "CollectionName", 
                repository.GetCollection(), 
                Cache.NoAbsoluteExpiration, 
                Cache.NoSlidingExpiration, 
                CacheItemPriority.NotRemovable, 
                null);
        }
    }
    
    public class MvcApplication : HttpApplication
    {
         public IEnumerable<CollectionItem> CollectionName
         {
             get { return HttpRuntime.Cache["CollectionName"] as IEnumerable<CollectionItem>; }
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing an ASP.NET MVC Application that currently uses it's own database ApplicationData
I've have quite small asp.net MVC 2 application to maintain/extend. Currently it uses hand
I have an ASP.NET MVC application that currently uses the WebClient class to make
I'm currently developing an asp.net mvc 2 application which uses the default SqlMembershipProvider for
Hello i am currently developing a ASP.NET MVC 3 application that uses the new
I am writing a Asp.net MVC 2 application that uses Forms Authentication and currently
I'm creating a MVC-application which currently uses EditorFor to gennerate a lot of views.
I'm currently debugging an ASP.NET MVC application that was just deployed to a different
I'm currently creating an MVC application that will likely to expand to include a
I am currently developing an MVC application in ASP.net. I am using AJAX.ActionLink to

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.