0

I am developing a VS 2008 web application in C#. I am trying to include a namespace that is stored in one of my folders. So instead of:

using ADONET_namespace

it is stored in "Admins" folder. How do I modify this aspx.cs file to include Admins/ADONET_namespace?

Currently I get following error from aspx.cs file: The type or namespace name 'ADONET_namespace' could not be found (are you missing a using directive or an assembly reference?)

2
  • 1
    your question is not clear. Folders structure and namespaces may be unrelated Commented May 21, 2010 at 0:12
  • what's not clear about it? All I'm trying to do is to store this namespace in a secured folder so only certain users may access it. Commented May 21, 2010 at 0:14

1 Answer 1

5

If you are developing within an ASP.NET website (eg., File -> New Web Site) and you want to reuse classes within your web app you need to put the classes in .cs files within the App_Code directory of the application, or you can compile them into a DLL and place that within the bin directory.

If you are developing within an ASP.NET web application project (eg., File -> New Project, New ASP.NET Web Application), then you may organize your class files however you wish within the substructure of that project, or you may add additional projects to the solution to arrive at a higher degree of separation between UI code and elements and your business or data logic.

And, of course, newer ASP.NET technologies such as MVC would follow conventions for storing controllers and things such as that, and the same about additional projects applies.

After you have organized your files in a way consistent with your application type, you may include using myNamespace; in whatever class or page that needs to be able to use those classes.

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

2 Comments

+1 this is what I meant. Specially in asp.net website you wont have dynamic compilation of ur code in app_code like in a website.
This is only true if he's using a Web Site "project" (created by File->New Web Site). If he used a Web Application Project (created by File->New Project) then he wouldn't have this problem, and could put his code whereever he liked.

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.