Sven
Sven

Reputation: 371

Namespaces not recognized in ASP.NET 5 MVC6 app

I'm trying out ASP.NET 5 with MVC 6 but have some issues. Using Visual Studio 2015 Comm

I create a model under namespace MyApp.wwwroot.Models. Then a service under namespace MyApp.wwwroot.Service. Here I reference my model. It just shows in black, not in blue. It also has no quick actions or squigly line. When I build it says "Build Succeeded". I have the same problem when I add a reference to Microsoft.AspNet.Mvc in my Controller. When I create a new controller and inherit from Controller. I have the same issue..

Is this VS or what could be the issue?

enter image description here

enter image description here

enter image description here

Upvotes: 0

Views: 617

Answers (2)

Daniel Grim
Daniel Grim

Reputation: 2271

It looks like you're trying to place code under the wwwroot folder. The wwwroot folder in ASP.Net Core (formerly ASP.Net 5) is used for hosting static content and these files are not parsed or compiled as C# code, but rather as static content that you want served (ex. html/css/javascript files). Moving these files out of the wwwroot folder should fix this issue if this is the case.

Upvotes: 2

pnm
pnm

Reputation: 148

When working in your FishtankApp.Services namespace, you need to expose your model namespace. this is done by adding the following using declaration at the top of the source code document you wish to use it on:

  using FishTankApp.Models ;

The same holds true for anything you wish to use that falls outside the scope of the current namespace you're working in.

Upvotes: 0

Related Questions