James Dudley James Dudley -4 years ago 137
ASP.NET (C#) Question

Two "Website" Namespaces?

Using ASP.NET 4.6 with WebForms. Created a static class in App_Code called Settings:

public static class Settings
{
// ... code ...
}


When trying to access from other static class also inside of App_Code folder get:

enter image description here

Also noticed I have two Website contexts:

enter image description here

Tried putting the Settings class inside the namespace "Website"; still have same issue. Issue only resolves when I declare the class like:

internal static class Settings
{
// ... code ...
}


I suspected I've done something wrong somewhere with namespaces; but I'm not sure what/where. What is causing the solution two have two "Website" namespaces?

After further digging I found that there are two Website "Containers" - not namespaces.

References view by namespaces:

enter image description here

References view by "containers":

enter image description here

Still digging in to try to figure this out...

Answer Source

The 'Build Action' for the file itself was set to 'Content' instead of 'Compile'. For some reason anytime I add a new class to the projects inside this solution they default to 'Content'. Once I set to compile I was back down to a single 'Website' container and everything worked as it should.

Build action

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download