Get System.Web.UI Page object from inside a Driver

Topics: General, Writing modules
Feb 11, 2013 at 8:13 AM
I created a module in which I cam trying to set the Page.Title for a page. We have a page that has its contents generated by a httpHandler and we want to have the page title be dynamic. I have tried to create the Page object from the IWorkContextAccessor interface but it keeps coming back null. My code is as follows:
private readonly IPageTitleService _pageTitleService;
private readonly RequestContext _requestContext;
private readonly IWorkContextAccessor _workContextAccessor;

public PageTitleDriver(IPageTitleService pageTitleService, RequestContext requestContext, IWorkContextAccessor workContextAccessor)
    _pageTitleService = pageTitleService;
    _requestContext = requestContext;
    _workContextAccessor = workContextAccessor;

protected override DriverResult Display(PageTitlePart part, string displayType, dynamic shapeHelper)
    var model = _pageTitleService.GetPageTitle(part.Id);
    if (model != null)
        var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext);
        if (context != null)
            var page = workContext.HttpContext.Handler as Page;
            if (page != null)
                page.Title = model.PageTitle;
    return null;
Is there something I am missing? I have tried using IHttpContextAccessor, and IOrchardServices but with the same result.
Feb 11, 2013 at 9:16 AM
Set Layout.Title.