MVC 4 @Scripts “does not exist”

后端 未结 24 1944
长发绾君心
长发绾君心 2020-12-12 11:20

I have just created an ASP.NET MVC 4 project and used Visual Studio 2012 RC to create a Controller and Razor Views for Index and Create Actions.

24条回答
  •  自闭症患者
    2020-12-12 12:21

    @Styles and @Scripts are 2 new helpers provided by System.Web.Optimization library. As the name suggests, they bundle and minify CSS and JavaScript files or resources respectively.

    Try including the namespace System.Web.Optimization either by @using directive or through web.config

    http://ofps.oreilly.com/titles/9781449320317/ch_ClientOptimization.html#BundlingAndMinification

    UPDATE

    Microsoft has moved the bundling/minification to a separate package called Microsoft.AspNet.Web.Optimization. You can download the assembly from nuget.

    This post will be useful to you.

提交回复
热议问题