【问题标题】:cannot add system.web.optimization无法添加 system.web.optimization
【发布时间】:2013-07-17 07:02:34
【问题描述】:

我目前有一个由经典的 asp.net 网络表单编写的项目。现在我不想将所有项目都转换为 mvc 4.0。这就是为什么我试图让我的项目成为混合项目。我添加了所有 mvc、路由库。

但我无法将 system.web.optimization 添加到我的项目中。在自动生成的代码中,我遇到了错误。

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.17929
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace ASP {
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Helpers;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Optimization; // the line i m getting error
using System.Web.Routing;


public class _Page_Views_Home_Contact_cshtml : System.Web.Mvc.WebViewPage<dynamic> {


    public _Page_Views_Home_Contact_cshtml() {

....

【问题讨论】:

  • “我遇到了错误。” - 那些东西通常包含有用的信息 - 即使你看不懂,其他人可能 - 这么关心添加细节吗?另外,只是为了检查一下,您知道引用和 using 指令之间的区别,不是吗?

标签: asp.net asp.net-mvc-4


【解决方案1】:

它在 ASP.NET MVC 4 中已过时

你可以从 nuget 得到你需要的东西:

Install-Package Microsoft.AspNet.Web.Optimization

SOURCE

其他帮助:
Adding the new ASP.NET Web Optimization framework to MVC4 projects after manually upgrading them

【讨论】:

  • 为了清楚起见,对于那些将旧网站迁移到最新 VS 的人,在添加 Microsoft.AspNet.Web.Optimization 包后,您将使用完整的调用 BundleTable、StyleBundle 和 ScriptBundle 类System.Web.Optimization.xxxxx 的路径(“xxxxx”为 BundleTable 等)。
猜你喜欢
  • 1970-01-01
  • 2014-05-25
  • 1970-01-01
  • 2012-07-03
  • 2015-03-14
  • 2015-02-15
  • 2012-03-17
  • 2013-03-17
相关资源
最近更新 更多