jtrohde
jtrohde

Reputation: 452

Visual Studio 2012 Not Generating Namespaces

My team recently moved an ASP.NET website project from VS 2010 to 2012. When creating a new page and code behind file in 2010, the file would be created with a namespace based on the folder the structure the file was created in. For example, a file named MyPage.aspx.cs created in MyProject -> Folder1 -> Folder2 would be generated looking like

namespace MyProject.Folder1.Folder2
{
    public partial class MyPage
    {

    }
}

In 2012, the same file is created without a namespace, and the folder structure is appended to the class name with underscores like

public partial class MyProject_Folder1_Folder2_MyPage
{

}

We prefer the look of the 2010 style as it seems much cleaner to us. How can we get new files to generate with namespaces in that manner? This seems like it should be a simple setting somewhere, but I cannot find any documentation on the issue.

Upvotes: 1

Views: 1278

Answers (1)

James Johnson
James Johnson

Reputation: 46067

This is happening because the project is configured as a Web Site instead of a Web Application. Try converting the to a web application and see if that addresses the behavior in question.

Regarding Web Site projects, MSDN states the following:

Explicit namespaces are not added to pages, controls, and classes by default, but you can add them manually.

Check out these link for details:

Upvotes: 3

Related Questions