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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:56:08+00:00 2026-05-26T04:56:08+00:00

My base page looks like: namespace ASDF.Mvc.ViewEngines.Razor { public abstract class WebViewPage<TModel> : System.Web.Mvc.WebViewPage<TModel>

  • 0

My base page looks like:

namespace ASDF.Mvc.ViewEngines.Razor
{
    public abstract class WebViewPage<TModel> : System.Web.Mvc.WebViewPage<TModel>
    {

        public ISomeHelper SomeHelper { get; set; }
    }
}

My views/web.config

<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="ASDF.Mvc.ViewEngines.Razor.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

How can I have this wired up such that SomeHelper will be wired up using Castle.

This is coming back null at the moment, I have wired up ISomeHelper already and things work fine for my controllers/repositories/service classes.

I’m guessing this WebViewPage is called somewhere where my container doesn’t have access to (like at the controller level).

How do I get this to work?

  • 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-26T04:56:09+00:00Added an answer on May 26, 2026 at 4:56 am

    The first thing about dependency injection into custom web pages like this is that you cannot use constructor injection. It’s a pity and I hope they will improve this in future versions. The reason for that is that the actual class that implements this is dynamically emitted at runtime by the ASP.NET engine.

    So we canonly use property injection at the moment.

    So one possibility is to use a custom IDependencyResolver. Unfortunately IDependencyResolver doesn’t play nice with Castle Windsor. Would have been a piece of cake with Ninject for example. All you would have to do is to decorate the SomeHelper property with the [Inject] attribute:

    [Inject]
    public ISomeHelper SomeHelper { get; set; }
    

    and it would have been automatically wired by Ninject as it uses a custom IDependencyResolver. I am afraid that with Windsor you will have to do this manually. So you could make your container public in Global.asax and then:

    public abstract class WebViewPage<TModel> : System.Web.Mvc.WebViewPage<TModel>
    {
        protected WebViewPage()
        {
            SomeHelper = MvcApplication.WindsorContainer.Resolve<ISomeHelper>();
        }
    
        public ISomeHelper SomeHelper { get; set; }
    }
    

    I know that this sucks but I am afraid it is the harsh reality. Or maybe switch to Ninject? It plays really great with ASP.NET MVC 3 and its IDependencyResolver.

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

Sidebar

Related Questions

Hello. I have a list that looks like this one: public class PagedList<T> :
I have usercontrols which inherit a base class which looks like this: BasePage.cs: using
I've got a generic base page class that I'd like to use with my
My setup currently looks like this application/controllers/register.php class register_Controller extends Base_Controller { public $restful
I have a class that looks like this: public class TextField : TextBox {
I'd like to check for the existence of the Session in a base page
The page is here: https://gentle-day-3026.herokuapp.com/ The css file like this: https://gentle-day-3026.herokuapp.com/stylesheets/base.css another is to
Thus for used base class for some commom reusable methods in every page of
My route looks like the following: map.namespace(:admin) do |admin| admin.resources :pages end and my
Currently I am using a basic error controller which looks like this: class ErrorController

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.