Call Service from View

Topics: General
Mar 1, 2012 at 10:12 PM

With Orchard 1.3.1 I call Service from a view in this way:

The View

@inherits Fanta.Helpers.ServiceView
@{
    var foo= FooService.Get(...);
}

---
The base service 
namespace Fanta.Helpers
{
    public abstract class ServiceView : WebViewPage {
        public ILeagueService FooService{ get; set; }
    }
}

And It working properly.

In Orchard 1.4 the service object FooSerive is null! Why?? I have the same code both in Orchard 1.3 and Orchard 1.4...

Thank you

Developer
Mar 1, 2012 at 10:21 PM

Perhaps you could try this instead (from within your view):

@{
    var fooService = WorkContext.Resolve<ILeageService>();
}
Mar 1, 2012 at 11:08 PM

Thank you! It works!