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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:21:54+00:00 2026-06-09T22:21:54+00:00

I have implemented a custom OutputCacheProvider public class MongoDBCacheProvider : OutputCacheProvider, IDisposable { …

  • 0

I have implemented a custom OutputCacheProvider

public class MongoDBCacheProvider : OutputCacheProvider, IDisposable { ... }

The cacheprovider is registered like so:

<outputCache defaultProvider="MongoDBCacheProvider" enableOutputCache="true"  >
  <providers>
    <add name="MongoDBCacheProvider" type="Mynamespace.Core.Caching.MongoDBCacheProvider, Mynamespace.Core" />
  </providers>
</outputCache>

I need to pass some arguments to the constructor. I want to use Ninject to bind my cache provider.

this.Bind<System.Web.Caching.OutputCacheProvider>()
    .To<Core.Caching.MongoDBCacheProvider>()
    .WithConstructorArgument("databaseName", dbName);

More arguments have to be passed, but this is just an example. I’m sure simple solutions exist to somehow get that string there, but i would prefer to use Ninject like i use for all other classes.

This fails with the message: “No parameterless constructor defined for this object.” The following binding doesn’t work either.

this.Bind<Core.Caching.MongoDBCacheProvider>().ToSelf()
    .InSingletonScope()
    .WithConstructorArgument("databaseName", dbName);

I have verified that the binding runs before the error occurs. ASP .NET somehow bypasses the ninject bindings.
There doesn’t seem to be any way to plug in a factory for it either.

Does anybody know how i can pass constructor arguments to a derived OutputCacheProvider?

Thank you.

  • 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-09T22:21:56+00:00Added an answer on June 9, 2026 at 10:21 pm

    You should be able to Inject into the object early in your web app life cycle by causing it to be injected during app startup.

    NB you will have to use Property Setter Injection in preference to Constructor Injection, as there is likely no way to get the Cache Provider Provider to give you control of the instance creation.

    See this blog post by @Remo Gloor

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

Sidebar

Related Questions

I have implemented a custom Table Model as follows: public class MyTableModel extends AbstractTableModel
I have implemented a custom list view which looks like the twitter timeline. adapter
I have implemented custom title bar feature using the following class CustomWindow . Other
I have implemented a custom designer class which inherits from DocumentDesigner. The standard Form
I have implemented custom class representing an enumeration possibilities similarily to this article :
Alright. I have implemented a custom JTable model that includes the whole @Override public
I have implemented a custom class of UISlider so the touchable areas are larger
I have implemented a custom ActionMapper which obtains the locale from the URI (the
I have implemented a custom view within another activity into a XML layout. The
In my WCF service I have implemented a custom encoder which inherits from System.ServiceModel.Channels.MessageEncoder

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.