user3610920
user3610920

Reputation: 1652

How to use @Scripts in MVC3 VS10 application

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

enter image description here

enter image description here

how to resolve this?

Upvotes: 1

Views: 58

Answers (2)

Rahul Nikate
Rahul Nikate

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

NicoXiang
NicoXiang

Reputation: 436

Install-Package Microsoft.AspNet.Web.Optimization 

In the Nuget Package Manager Console.

Upvotes: 0

Related Questions