public static IHtmlString Render(string alias, HtmlHelper<RenderModel> helper)
{
try
{
// If request is coming from frontend then always show frontend content, check authentication if it comes from backend (.aspx)
var isAuthenticated = false;
if (HttpContext.Current.Request.Path.Contains(".aspx"))
{
isAuthenticated = Authorize.isAuthenticated();
}
var view = ViewHelper.Get(alias, isAuthenticated);
var culture = CultureInfo.CreateSpecificCulture(UmbracoContext.Current.PublishedContentRequest.Culture.Name);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
var model = helper.Partial(view.viewName, view);
return new HtmlString(model.ToString());
}
catch (Exception ex)
{
Log.Error("Canvas Error on Render in API.", ex);
return new HtmlString("");
}
}
}