The type or namespace name 'Optimization' does not exist in the namespace 'System.Web'

后端 未结 7 518
花落未央
花落未央 2021-02-05 01:32

I am deploying a new website as my main site and it works beautifully.

All of my applications under the root url work as well, except for one. It is a legacy system (c#

相关标签:
7条回答
  • 2021-02-05 01:56

    In Visual Studio .. Go to your project and see the References tree.

    right click System.Web.Optimization and choose Properties

    look for the path , you will find it empty if that is the case then look in your PC for the file names System.Web.Optimization.dll and copy it in the bin folder of your project and that will resolve it

    0 讨论(0)
  • 2021-02-05 01:57

    Check the Bin folder for the legacy application. It may simply need you to drop in that DLL. The System.Web.Optimization namespace exists as of ASP.NET 4.5 so it may not even be supported. The legacy App might be older than that.

    0 讨论(0)
  • 2021-02-05 02:00

    I faced same problem after create a new area in MVC5. There is auto generate web.config file. Check your web.config file under Views folder there is a line

    <add namespace="System.Web.Optimization" />
    
    1. if you need this then install it using following command.

      Install-Package Microsoft.AspNet.Web.Optimization
      

      at Package Manager Console like below

    2. If you think no need then simply remove <add namespace="System.Web.Optimization" /> line from following section in web.config file

      <namespaces>
         <add namespace="System.Web.Mvc" />
         <add namespace="System.Web.Mvc.Ajax" />
         <add namespace="System.Web.Mvc.Html" />
         <add namespace="System.Web.Routing" />
         <!--<add namespace="System.Web.Optimization" />-->
         <add namespace="AutoParts.Web" />        
      </namespaces>
      
    0 讨论(0)
  • 2021-02-05 02:11

    Removing the reference from Views/Web.config worked for me.

    0 讨论(0)
  • 2021-02-05 02:17

    I was just experiencing: "CS0234 C# The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)" and found this stackoverflow page. -- The cause for me was due to me renaming the web form (aspx page) I was working with, I also wanted to rename the public partial class behind that form. Doing so resulted in the mentioned error code. I added "using System.Web.Optimization;" to the code behind (C#), "cleaned" the solution, then "built" then solution, then "rebuilt" the solution and now the error is gone and that using statement wasn't being used, so I got rid of it. My solution no longer has that or any errors so I figured I'd share this weird story. I probably didn't need to use that "using" statement, but whatever.

    0 讨论(0)
  • 2021-02-05 02:20

    Main to Area

    @Html.ActionLink("My Area Home", "Index", "Home", new { area = "MyArea" }, null)
    

    Area to Main

    @Html.ActionLink("Home", "Index", "Home", new { area = "" }, null)
    
    0 讨论(0)
提交回复
热议问题