aleczandru
aleczandru

Reputation: 5449

The type of namespace 'Web' does not exist in the namespace 'System' (are you missing an assembly reference) in asp.net core

net core application that I have not opened in a month. The application worked last time I opened it but now when I try to build the project I get the following error in the Page class which is not a class from my project:

enter image description here

This are errors that gets displayed on the console:

enter image description here

This is what I have in my project.json file:

    {
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Anyone know what is wrong here?

Upvotes: 2

Views: 3028

Answers (3)

Abhishek Chokra
Abhishek Chokra

Reputation: 1381

That will not work the way you think. When you use .Net Core MVC or.Net Core 2 MVC against the full framework (ASP .Net MVC) it's true that the System.Web namespace exists and could technically be called but it won't work like you want.

Solution - In the Solution Explorer, right click on the node_modules folder and click "Exclude From Project"

Precaution - Do not delete any file inside node_modules or folder itself.

Reason - If you are working on a client side app that includes npm and node_module folders with large amount of dependencies while using website project in Visual Studio, which is a terrible solution.It results in very slow load times and/or file load errors.

If you have a node_modules folder in your project it will affect the files in the project as well as for publishing. Finally, using a node_modules massive folder in your project there is no way to limit files or folders and end up giving errors.

Upvotes: 0

Exec21
Exec21

Reputation: 827

You need to go to node_modules and manually delete Page.aspx.cs and all .cs files. Selenium-webdriver contains a test folder with it. I have had the same problem. Be sure to show all files so you will see the node modules folder

Upvotes: 3

Pawel
Pawel

Reputation: 31610

Not sure how it could work before. You can't use System.Web/WebForms with ASP.NET Core.

Upvotes: 2

Related Questions