Shazwazza / ClientDependency

DEPRECATED. A library for managing CSS & JavaScript dependencies and optimization in ASP.Net
139 stars 65 forks source link

Forced provider not rendering #120

Open Lachlann opened 7 years ago

Lachlann commented 7 years ago

Hello I have CD v1.9.2 , Cd -MVC 1.8.0 and CD- MVC5 1.8.0 installed and running on an Umbraco 7.5.4 site.

I am trying to use a forced provider to allow me to split up my CSS to render in two different locations.

I have edited my config like so:

  <mvc defaultRenderer="StandardRenderer">
    <renderers>
      <add name="StandardRenderer" type="ClientDependency.Core.FileRegistration.Providers.StandardRenderer, ClientDependency.Core" />
      <add name="Ie9Renderer" type="ClientDependency.Core.FileRegistration.Providers.StandardRenderer, ClientDependency.Core" />
      <add name="LazyLoadRenderer" type="ClientDependency.Core.FileRegistration.Providers.LazyLoadRenderer, ClientDependency.Core" />
    </renderers>
  </mvc>

and have referenced my css in the layout view as follows:

Html.RequiresCss(new CssFile("/ie/css/ie8.css") {ForceProvider= "Ie9Renderer" });

and then am calling it like:

  @Html.Raw(Html.RenderCssHere("Ie9Renderer"))

But nothing renders. The main referenced files still reference correctly.

kipusoep commented 6 years ago

Same issue for me, no comments yet since a year? 😮

Shazwazza commented 6 years ago

Can you replicate this with a very simple setup? Perhaps you have cached views? What version?

@kipusoep please describe your own issue, is it exactly the same as above?

I used this just the other day and it was working so need to know specifics on how to replicate.

Also note that @Html.Raw to use RenderCssHere isn't necessary

kipusoep commented 6 years ago

I ran into this issue with a project we inherited from another company. It was an umbraco v7.3.5 solution and I upgraded it to v7.11.1 via v7.5.14, v7.7.13 and v7.9.6. Therefore CD is upgraded from v1.8.4 to v1.9.6. I don't have CD-Mvc installed, only ClientDependency-Mvc5 v1.8.0.

There is a head and foot view which contained these snippets:

@{
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/angular.js") {ForceProvider = "HeadRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/angular-sanitize.js") {ForceProvider = "HeadRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/angular-locale_nl-nl.js") {ForceProvider = "HeadRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/iframeresizer.min.js") {ForceProvider = "HeadRenderer" });
}
@Html.Raw(Html.RenderJsHere("HeadRenderer"))
@{

    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/promise.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/jquery.min.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/ui-bootstrap-tpls-1.2.1.min.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/lodash.min.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/TweenMax.min.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/jquery.scrollTo.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/bootstrap.min.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/angular-tooltips.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/ng-password-strength.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/moment.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/pikaday.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/vendor/pikaday.jquery.js") { ForceProvider = "FootRenderer" });
    Html.RequiresJs(new JavascriptFile("~/static/js/main.js") { ForceProvider = "FootRenderer" });
}

@Html.Raw(Html.RenderJsHere("FootRenderer"))

This was working fine before the upgrades, after the upgrades nothing got rendered anymore. In the meantime I went with the Bundler stuff from Bundler & Minifier for VS.