1

We have a website made with Umbraco/Razor.

I upgraded the template with ClientDependency (Razor) as below.

@using ClientDependency.Core.Mvc

@{
    Layout = null;
    @Html.RequiresCss("~/css/normalize.css")
    @Html.RequiresCss("~/vendor/bootstrap-3.1.1/css/bootstrap.min.css")
    @Html.RequiresCss("~/vendor/font-awesome-4.0.3/css/font-awesome.min.css")
    @Html.RequiresCss("~/css/bootstrap.css")
    @Html.RequiresCss("~/css/RichTextEditor.css");
    @Html.RequiresJs("~/js/vendor/modernizr-2.6.2.min.js")
    @Html.RequiresJs("~/scripts/SubscribeProcess.js")
    @Html.RequiresJs("~/scripts/CookieMethods.js");
    @Html.RequiresJs("~/scripts/DownloadProcess.js");
}

I added this in the header

 @Html.RenderCssHere()
 @Html.RenderJsHere()

After running the website I get an message on top of the body.

System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]
System.Web.Mvc.HtmlHelper`1[Umbraco.Web.Models.RenderModel]

This message repeats 9-times. Just as the amount of file loaded with the @Html.RequiresCss or @Html.RequiresJs.

Does anyone have this issue or know an solution?

Thanks in advance!

Kevin Restiaens
  • 218
  • 3
  • 15

2 Answers2

5

The @ before Html.RequiresJs needs to be deleted.

Result:

@using ClientDependency.Core.Mvc

@{
    Layout = null;
    Html.RequiresCss("~/css/normalize.css")
    Html.RequiresCss("~/vendor/bootstrap-3.1.1/css/bootstrap.min.css")
    Html.RequiresCss("~/vendor/font-awesome-4.0.3/css/font-awesome.min.css")
    Html.RequiresCss("~/css/bootstrap.css")
    Html.RequiresCss("~/css/RichTextEditor.css");
    Html.RequiresJs("~/js/vendor/modernizr-2.6.2.min.js")
    Html.RequiresJs("~/scripts/SubscribeProcess.js")
    Html.RequiresJs("~/scripts/CookieMethods.js");
    Html.RequiresJs("~/scripts/DownloadProcess.js");
}
Kevin Restiaens
  • 218
  • 3
  • 15
0

I think the previous answer was correct in the text - it should not have the @ symbol - but the pasted code still has the @ symbols. Instead it should be, for example:

@{
Layout = null;

Html.RequiresCss("~/css/jquery-ui.css");
Html.RequiresJs("~/scripts/jquery.min.js", 1);
Html.RequiresJs("~/scripts/jquery.dropotron.min.js", 2);
Html.RequiresJs("~/scripts/config.js", 3);
Html.RequiresJs("~/scripts/skel.min.js", 4);
Html.RequiresJs("~/scripts/skel-layers.min.js", 5);
Html.RequiresJs("~/scripts/init.js", 6);
Html.RequiresJs("~/scripts/konami.js", 7);
Html.RequiresJs("~/scripts/konamicode.js", 8);
Html.RequiresJs("~/scripts/jquery-ui.min.js", 9);
Html.RequiresJs("~/scripts/slimmage.settings.js", 10);
Html.RequiresJs("~/scripts/slimmage.min.js", 11);
Html.RequiresJs("~/scripts/ion.sound.min.js", 12);
Html.RequiresJs("~/scripts/jquery.ion.sound.min.js", 13);

}

And then as the OP wrote, add this into the header:

 @Html.RenderCssHere()
 @Html.RenderJsHere()

This worked for me and ClientDependency is now working.

ladygargar
  • 597
  • 10
  • 14