Error while trying to create a Controller or Apicontroller

Asked

Viewed 249 times

0

I created an empty Asp.Net Core 2.0 project (no scaffold). DDD model and etc. However when I try to create my controller, whether inherited from Apicontroller or Controller, it gives error:

Controller is a namespace, but is used as a type

[Produces("application/json")]
[Route("api/Message")]
public class MessageController : Controller
{
}

In the above example I tried to create an Apicontroller and came as above.

  • At core he inherits only Controller. You didn’t accidentally create some namespace Controller?

  • Change the folder name to Controllers and namespace to Controllers

  • @Netinhosantos, answers that I mark. It was the name of the same folder.

  • @pnet responded. Att.

  • Just down lately, all right. It was a few days without opening the site that is now just down, although there is a guy on the site who always gives me Downvote, regardless of the construction of the question, but this is another subject.

  • See also the ASP NET Core 2 Razor Pages, which further simplifies this.

  • thanks @Tony, I’ll give a study yes

Show 2 more comments

1 answer

2


Change the folder name to Controllers and namespace to Controllers.

namespace MeuApp.Controllers
{
   public class MessageController : Controller
   {
       // Seu código...
   }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.