System.Web.WebPages.Assets

Topics: ASP.NET MVC, ASP.NET Web Pages
Jun 4, 2012 at 5:02 AM

Does anyone know where Assets dissapeared to?

From beta -> RC, it seems to have gone awol, and I don't see any hints as to what I should be using in its place.

 

(It doesn't seem to exist in the initial commit to git, so I'm guessing it was removed prior to the migration + open sourcing).

Jun 4, 2012 at 3:50 PM

Assets Management has been moved out of WebPages and in to the Optimization and Bundling framework. It's available on NuGet[1] as "Microsoft.AspNet.Web.Optimization". It also comes pre-installed in MVC templates (and I believe WebAPI templates as well).

As a result of the move, the type has also moved to a different namespace, though I don't remember exactly what it is off the top of my head. I believe it's something like Microsoft.Web.Optimization.

Hope that helps!
-Andrew

[1] http://nuget.org/packages/Microsoft.AspNet.Web.Optimization

Jun 4, 2012 at 11:14 PM

Awesome, that's solved it completely, thanks!

Jun 5, 2012 at 12:28 AM

Woops, I spoke too soon, a victim of some DLL caching.

The Web.Optimisation dll does not contain the Assets/AssetsManager classes, and I don't see how it offers comparable functionality (they seem complimentary in general).

Jul 5, 2012 at 5:23 PM
Edited Jul 5, 2012 at 5:24 PM

This from my research into the issue as someone that recently updated to WebMatrix 2 RC and found code breaking

http://www.asp.net/web-pages/overview/whats-new/top-features-in-web-pages-2

Changes for the RC Version (June 2012)

The functionality for bundling and minification has been removed from the core ASP.NET Web Pages 2 assemblies. As a consequence, the Assets helper listed later in this document is not available. Instead, you must install the ASP.NET Optimization NuGet package. For more information, see Bundling and Minifying Assets in an ASP.NET Web Pages (Razor) Site.

Changes for the Beta Version (February 2012)

The Scripts helper for assets (resource) management has been replaced with the Assets helper, which has slightly different methods, such as the following:
For Scripts.Add , use Assets.AddScript
For Scripts.GetScriptTags, use Assets.GetScripts

This is a breaking change; the Scripts class is not available in the Beta release. The code examples in this document that use asset management have been updated with this change.

http://www.asp.net/web-pages/tutorials/performance-and-traffic/bundling-and-minifying-assets-in-an-aspnet-web-pages-(razor)-site

Note The RC release of ASP.NET Web Pages 2 does not support bundling and minification because the package that contains the required elements is not yet available in Microsoft WebMatrix. We apologize for this inconvenience. The package is expected to be available in the final release of ASP.NET Web Pages 2 and WebMatrix 2.