Alexa Adrian
Alexa Adrian

Reputation: 1858

How to use namespaces in Asp.Net c# Project?

I wonder how to use namespaces in asp.net c# project? I am prepend in classes defined in AppCode

namespace MyNamespace
{
    class code My Class
    {
    }
}

If i do so then I see that in a view where I use this class must include this namespace(of course). Can't I include this in webconfig to include it all over? Update:

The reason I want to use namespaces is because I want to create a dll file of files from AppCode so application will run quicker. Even though I see that no dll is built when I build the site.

Upvotes: 1

Views: 1933

Answers (2)

Gabriel Scavassa
Gabriel Scavassa

Reputation: 594

If you are using a Web Application and have a Class or ClassLibrary and want to call this class in your code behind ".asc" .

You can Add Reference in the WebApplication, so you choose the Class in Project tab. Then u can call : using Class.namespace ...

Upvotes: 1

Denis Agarev
Denis Agarev

Reputation: 1529

First of all if you are planning to use WebSite project change it to Web Application Project, web site project is mostly deprecated and just allows you less functionality in project configurating (surely their is some in advantages like "copy site" but i don't think they are very usefull).

So in this type of project you don't need to use App_Code and surely it's easy to add namespace to web.config:

Upvotes: 1

Related Questions