Pregunta

Consider the following scenario

I have a MVC5. I would like to have a base view with some dependencies as:

public class BasicView<T> : WebViewPage<T>                             
{        
    public IResourceService ResourceService { get; set; }       

    public override void Execute()
    {

    }
}

Then in the webconfig....

<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />  
    <pages pageBaseType="BasicView">

The property is never injected :(

when I use the same dependency on a regular constructor, works without problems.

What am I missing here? Windsort documentation says the container will try to resolve that kind of Properties.

¿Fue útil?

Solución

Windsor does not inject into your views because it does not own the view creation process.

You have to use Windsor as service locator in this scenario. See this answer to find out how to use it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top