0

Normally I can add classes to my ASP.NET project, but it is very weird and now I am getting this error when adding a class:

enter image description here

Also my project doesn't use any namespaces anymore. I created another clean ASP.NET project, but the same issue appears there too...

When I click "Yes" (Ja) then the class will be added to the project in a folder names App_Code, without namespaces, and when I click "No" (Nee) then the class will be added to the normal project folder, also without namespaces.

Anyone who can help me with this problem? I can't create new instances of my classes.

4
  • Did you create a new web site or web application? Commented Jul 5, 2013 at 9:06
  • Yes, I did! Menu -> File -> New -> Website Commented Jul 5, 2013 at 9:07
  • 1
    In your case I think you should create a web app, not a web site. File New Project Web / New web application Commented Jul 5, 2013 at 9:10
  • Wow really? Didn't know that a web application and a new website were different... Commented Jul 5, 2013 at 9:11

2 Answers 2

2

You are wanting to create a WAP: File → New → Web Application Project.

Websites use special folders. By putting code inside App_Code folder, it avoids JIT compilation issues. Namespaces are still there, but taken care of by the framework. Check properties, you will find the global namespace there.

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

Comments

0

You have created new project as "ASP.NET Web Site"

options:

  1. re create a new Project.. "ASP.NET Web Application"

  2. create a new Project.. "Class Library" in same solution then add reference form your website (right click on your web site project > "Add References.." > projects tab )

  3. add any classes into App_Code directory

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.