Try our conversational search powered by Generative AI!

How to get full refresh to work in MVC razor


I have tried to get full refresh to work with MVC and razor the way episerver suggests but so far no luck. I will write below what I did and also what workaround I used to get it to work.

I have a boolean property on one of my blocks that adds a border. What I wanted to achieve was to make a preview page for the block that updated the visuals of the block when the value of that Boolean changed. This required a page refresh then the property changed. I tried following this example in the episerver sdk .

This is what I did.
In the controller I added AddFullRefreshFor for the border Boolean.

var editingHints = ViewData.GetEditHints<ViewModel,EpiBlock>();


In the view I added the full refresh method and the property.

Border: @Html.PropertyFor(m=>m.EpiData.Border)


This did not work.
It looks like there is a bug in the FullRefreshPropertiesMetaData method.

public static MvcHtmlString FullRefreshPropertiesMetaData<TModel>(this HtmlHelper<TModel> helper)
      if (RequestContextExtension.GetContextMode(helper.ViewContext.RequestContext) == ContextMode.Edit)
        IList<EditHint> list = helper.ViewData[ViewDataKeys.FullRefreshProperties] as IList<EditHint>;
        if (list != null && list.Count > 0)
          return PropertyExtensions.FullRefreshPropertiesMetaData((HtmlHelper) helper, Enumerable.ToArray<string>(Enumerable.Select<EditHint, string>((IEnumerable<EditHint>) list, (Func<EditHint, string>) (e => e.ContentDataPropertyName))));
      return MvcHtmlString.Empty;


The helper.viewdata returns a list of strings that can't be cast to a IList<EditHint> and thus it will always be null.


The solution that I did was to write my own extension method that solves this.

public static MvcHtmlString FullRefreshPropertiesMetaDataThatActuallyWorks<TViewModel>(this HtmlHelper<TViewModel> me)
             var refreshProperties = me.ViewData[ViewDataKeys.FullRefreshProperties] as IEnumerable<string>;
             if(refreshProperties != null)
                 return me.FullRefreshPropertiesMetaData(refreshProperties.ToArray());
             return MvcHtmlString.Empty;

    And call this method in the view instead.

Feb 06, 2013 15:45


That sure looks like a bug. I'll add it to our bug tracker.

Thanks for reporting this, and also for providing a work around.

Bug registered as: #95628: Not possible to add full refresh using the FullRefreshPropertiesMetaData extension method


Per Gunsarfs
EPiServer Development Team

Edited, Feb 06, 2013 16:35
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.