Why I don’t like Web Forms in EPiServer

Posted on Updated on

It can be avoided using Macio code (lambdas).


Fill CurrentPage after PostBack in MVC

Posted on

public class PageContextActionFilter : IResultFilter
    private readonly IContentLoader _contentLoader;

    public PageContextActionFilter(IContentLoader contentLoader)
        _contentLoader = contentLoader;

    public void OnResultExecuting(ResultExecutingContext filterContext)
        var model = filterContext.Controller.ViewData.Model as IPageViewModel<StandardPage>;
        if (model == null)

        // code like in Alloy Template

        // When ViewModel is posted back to server by POST, CurrentPage is null, so its set here
        if (model.CurrentPage == null)
            var pageReferene = filterContext.RequestContext.GetContentLink();
            var concreteModel = model as PageViewModel<StandardPage>;
            if (concreteModel != null)
                var currentPage = _contentLoader.Get<StandardPage>(pageReferene);
                concreteModel.CurrentPage = currentPage;

    public void OnResultExecuted(ResultExecutedContext filterContext) { }