Reputation: 1652
I have a MVC3 application in Visual Studio 2010 . I need to refer the scripts/styles in layout page using following tag
@System.Web.Optimization.Styles.Render("~/Content/css")
@System.Web.Optimization.Scripts.Render("~/Scripts/script")
But I am unable to use like this, since System.web,optimization is not available from _Layout.cshtml( even though the dll is referred in the project).Please refer to below image
how to resolve this?
Upvotes: 1
Views: 58
Reputation: 6337
First install Microsoft.AspNet.Web.Optimization
using Package Manager Console using below command.
Install-Package Microsoft.AspNet.Web.Optimization
Next you need to reference the dll System.Web.Optimization.dll
in your web project then you can add this namespace @using System.Web.Optimization in your
_Layout.cshtml`.
Also make sure System.Web.Optimization.dll
is present in bin folder in project.
Upvotes: 1
Reputation: 436
Install-Package Microsoft.AspNet.Web.Optimization
In the Nuget Package Manager Console.
Upvotes: 0