In my solution, I have the tags inserted in the head. When I run the application, these tags are rendered inside the body.
I've also noticed that the browser detects BOM at the beginning of the body.
If I comment
the @Html.RenderWidget("Footer", "Index");
that is inside the footer, the application correctly renders the tags in the head and without the BOM.
<footer>
@Html.RenderWidget("Footer", "Index");
@if (AbTesting.CheckVariant("sticky_phone_number_ski", "B"))
{
@Html.Partial("_CtaPanel")
}
</footer>
There is my elements tab on browser
My WidgetHelper.cs looks like this
public static class WidgetHelper
{
public static MvcHtmlString RenderWidget(
this HtmlHelper htmlHelper,
string widgetName,
string actionName = "",
object parameters = null)
{
var widget = ReflectionHelper.GetAllWidgetControllers().SingleOrDefault(wdg => ReflectionHelper.GetWidgetName(wdg) == widgetName.ToLower());
if (widget == null)
{
throw new Exception($"Widget with the name {widgetName} not found");
}
return RenderWidget(htmlHelper, widget, actionName, parameters);
}
public static MvcHtmlString RenderWidget(
this HtmlHelper htmlHelper,
Type widgetType,
string actionName = "",
object parameters = null)
{
try
{
var context = htmlHelper.ViewContext.HttpContext;
if (widgetType == null)
{
throw new ArgumentNullException(nameof(widgetType));
}
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
var builder = new ControllerBuilder();
var widgetName = ReflectionHelper.GetWidgetName(widgetType);
var widgetController =
builder.GetControllerFactory().CreateController(context.Request.RequestContext, widgetName) as
WidgetController;
if (widgetController == null)
{
return null;
}
if (string.IsNullOrEmpty(actionName))
{
actionName = widgetController.RouteData.GetRequiredString("Action");
}
var invoker = widgetController.ActionInvoker as WidgetActionInvoker;
var action = invoker?.InvokeActionWithActionResult(widgetController.ControllerContext, actionName, parameters) as IWidgetResult;
return action == null ? null : new MvcHtmlString(action.ResponseOutput.ToString());
}
catch (HttpException e)
{
throw e;
}
catch (Exception e)
{
LogManager.GetCurrentClassLogger().Error(e);
return htmlHelper.ViewContext.HttpContext.Request.IsLocal ? new MvcHtmlString($"<p style='color: red'>Widget {widgetType?.FullName} has broken. Please see logs for more details.</p>") : null;
}
}
}
I have the same problem when I use others RenderWidget in the header. So I believe the problem is there.
Do you have any idea what could be causing this issue?