1

I have an empty asp.net core app. I have added a controller to the application. When I try to compile the application it throws the below error

'Controller' is a namespace but is used like a type

The source is below

enter image description here

However if I prefix Controller with the namespace as shown below then it works fine.

enter image description here

Why is this ?

1 Answer 1

5

Look at your namespace, WebApplication1.Controller. Compiler thinks you want that instead of the Controller class. Rename your directory and namespace to be plural Controllers as is the usual practice and you won't have this issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.