在Mvc4中的_Layout.cshtml中的Styles.Render调用上出现WebGrease错误 [英] WebGrease error on Styles.Render call in _Layout.cshtml in Mvc4

查看:426
本文介绍了在Mvc4中的_Layout.cshtml中的Styles.Render调用上出现WebGrease错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加绑定到我的Mvc4 web项目。我采取的步骤:

I'm trying to add bundling to my Mvc4 web project. The steps I took:


  1. 添加了对我的项目的引用 System.Web.Optimization

  2. 中添加 @ Styles.Render(〜/ Content / css) ; of _Layout.cshtml

  3. 添加 BundleConfig.RegisterBundles(BundleTable。 Bundle); 至 Global.asax.cs

  4. 新增 BundleConfig.cs (〜/ Content / css)添加到到我的 App_Start 〜/ Content / site.css));
  5. 在我的内容文件夹中添加了一个简单的 site.css
  1. Added a reference to my project to System.Web.Optimization
  2. Added @Styles.Render("~/Content/css") within <head> of my _Layout.cshtml
  3. Added BundleConfig.RegisterBundles(BundleTable.Bundles); to Global.asax.cs
  4. Added BundleConfig.cs to my App_Start folder with bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css")); within RegisterBundles(...) method
  5. Added a simple site.css within my Content folder.

我从上面步骤#2得到的错误是无法加载文件或程序集'WebGrease,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其一个依赖关系。系统找不到指定的文件。

The error that I get on the line from step #2 above is Could not load file or assembly 'WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

我缺少一个DLL引用或者什么?注意,我最初从一个空白的Mvc4项目开始。

Am I missing a DLL reference or something? Note that I started originally from a blank Mvc4 project.

推荐答案

在过去一天左右,找出了一个解决方案。基本上你只需更新webgrease。

Over the last day or so I was having this issue too but I figured out a solution. Basically you need to just update "webgrease".

这是我做了更新webgrease:

Here's what I did to update webgrease:


  1. 右键单击解决方案资源管理器中的项目解决方案。

  2. 点击管理NuGet套餐以获取解决方案

  3. 转到左侧的更新部分

  4. 搜索WebGrease

  5. 然后更新WebGrease

  1. right click your project solution in your solution explorer.
  2. Click "Manage NuGet Packages for Solution"
  3. Go to the updates section on the left
  4. Search "WebGrease"
  5. Then update "WebGrease"

这篇关于在Mvc4中的_Layout.cshtml中的Styles.Render调用上出现WebGrease错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆