U4-2330 - Client Dependency not working in MVC v6

Created by Peter Gregory 05 Jun 2013, 16:29:07 Updated by Shannon Deminick 21 Jun 2017, 07:57:25

I am having trouble getting CDF which ships with v6 to work in MVC views. My Script registrations look like this.

@{ Html.RequiresCss("/css/royalslider1.0.3.css") .RequiresCss("/css/rs-custom.css");

	Html.RequiresJs("~/scripts/libs/jquery.royalslider.custom.min.js");

}

and on my _Layout I have the following

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

However what gets output to the HTML is as follows

<!--[Css:Name="StandardRenderer"]//--> <!--[Javascript:Name="StandardRenderer"]//-->

Comments

Asbjørn Riis-Knudsen 05 Jun 2013, 18:05:16

Umbraco 6.0 and previous versions use an older version of the Client Dependency Framework, which doesn't output the HTML correctly. You have to wrap it in Html.Raw(), like this: @Html.Raw(Html.RenderCssHere()) @Html.Raw(Html.RenderJsHere())

This has been fixed in 6.1, which uses a newer version of the Client Dependency Framework. Beware of U4-2315, if you upgrade to 6.1 (an easy fix is available in that bug)


Shannon Deminick 05 Jun 2013, 21:54:57

That is correct, you need to do ensure you use Html.Raw like @Asbjørn mentions. The other thing to ensure is that you have the CDF module registered properly in your web.config. You should just upgrade to the latest CDF version on Nuget (1.7.0.2) and the MVC one is 1.7.0.0 And depending on how old the CDF version you are upgrading from, you can read this too: https://github.com/Shandem/ClientDependency/wiki/1.6.0#breaking-changes Also in version 1.6+ if you want you can configure CDF to work with MVC razor views without the HttpModule: https://github.com/Shandem/ClientDependency/wiki/Mvc#setup


Shannon Deminick 21 Jun 2017, 07:57:25

Closing issue due to inactivity - see blog post for details https://umbraco.com/blog/issue-tracker-cleanup/


Priority: Normal

Type: Bug

State: Closed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.0.5

Due in version:

Sprint:

Story Points:

Cycle: