I have the below surface controller that has an Ajax call from the UI but when it tries to instantiate the SelectViewModel() it is giving me an error with the UmbracoHelper.
"System.InvalidOperationException: 'Cannot return the IPublishedContent because the UmbracoHelper was not constructed with an IPublishedContent.'"
Am I supposed to instantiate the UmbracoHelper again or can I not create ViewModelObjects within an Ajax call? Any help appreciated.
public class SelectSurfaceController : BaseSurfaceController
{
[HttpGet]
public ActionResult TravellersTemplate(int count)
{
var model = new SelectViewModel();
model.TravellersDatesOfBirth = Enumerable.Range(1, count).Select(x => new DateTime()).ToList();
return PartialView("_Travellers", model);
}
public class SelectViewModel : LayoutViewModel
{
public SelectViewModel() : base(Current.UmbracoHelper.AssignedContentItem) { }
public SelectViewModel(IPublishedContent content) : base(content) { }