开发者

Dependency inject IOrchardServices into aspx codebehind constructor

The team and I are looking at Orchard to use as our CMS. We have a fairly large ASP.NET 4.0 WebForms app and we can only migrate the bits one piece at a time. With that in mind, we will still serve our aspx pages and slowly convert them into the CMS as time allows.

I've noticed on the docs @ orchardproject.net/docs, link here, about how one does authorization inside a module. So all that has to be done is include IOrchardService in the constructor of a controller and it'll get injected at runtime.

public AdminController(IMyService myService, IOrchardServices orchardServices) {
    _myService = myService;
    Services = orchardServices;
}

Because the conversion process will be slow, ¿can I pro开发者_如何转开发vide a constructor with the IOrchardServices on a System.Web.UI.Page subclass?

// something like this
public partial class Test : System.Web.UI.Page
{
    IOrchardServices _service;

    public Test(IOrchardServices orchardServices)
    {
        _service = orchardServices;
    }
}

This does not work, throws an exception expecting a default constructor. If I place the default constructor, the page loads correctly but IOrchardServices is not injected. ¿Is this even possible?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜