1

How do you understand "No control over your namespaces" namespace issue, quoted from,

http://reddnet.net/code/asp-net-web-site-vs-web-application-project-part-2/

Here are more background:

one of the cons of web site project type of VSTS 2005 is, my confusion is what exactly means "no control over your namespace"?

  • No control over your namespaces. Sure, you can manually add namespaces to pretty much anything, but visual studio will fight you every step of the way. With generated code such as ADO.NET DataSets and such, this gets very hard to control. Eventually you will give up and just let VS put everything in the default namespace. In large applications this gets very annoying, especially if you like a well structured application.

Appreciate if anyone could show a sample here.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
George2
  • 44,761
  • 110
  • 317
  • 455
  • 7
    Are you expecting everyone on SO to read the entire blog post to understand your question? – Metro Smurf Jul 01 '09 at 16:26
  • 1
    I haven't any idea what he's talking about... I (have to) use Websites a lot and don't encounter any problem with namespaces. – Cerebrus Jul 01 '09 at 16:30
  • Sorry Metro, I have added more background information, hope people could understand what I mean withou reading the whole blog article. – George2 Jul 01 '09 at 16:33
  • 1
    Dupe: http://stackoverflow.com/questions/1056797/web-application-projects-v-s-web-site-projects – womp Jul 01 '09 at 16:53
  • The link does not answer my specific question about namespace issue, and the link you mentioned is very nice to describe the general pros and cons about WebSite v.s. Web Application. :-) Any ideas or comments to my original question? – George2 Jul 03 '09 at 16:18

2 Answers2

1

Just test this: create a Web Application and a Web Site, then take a look to the namespaces created into the Default.aspx.cs:

  • WebSite: has no namespace
  • WebApplication: has namespace

When you have a very big application it's impossible to find your classes without namespaces.

Now create a DataSet:

  • WebSite: no .Designer.cs created -> namespace will be created automatically on the fly
  • WebApplication: .Desinger.cs created with proper namespace.
jmservera
  • 6,454
  • 2
  • 32
  • 45
  • @jmservera, 1. even if WebSite project type does not generate namespace, we could add the namespace manully by ourselves, is that fine? 2. "Now create a DataSet" -- not sure what do you mean create a DataSet. I always programmatically create DataSet by using new DataSet(...) in my code, what do you mean "create a DataSet" here? What is the impact if no .Designer.cs created? – George2 Jul 03 '09 at 15:32
  • @George2, I meant: Right Click Web Site->Add new item...->DataSet, then you design a typified dataset definition into your project, that creates a class for it. If you do it into a WebSite you cannot set its namespace manually because each time you design it it will be overwritten. – jmservera Jul 03 '09 at 22:03
1

George, Web Sites are not specific to VSTS. That's a normal Visual Studio feature, haunting us since Visual Studio 2005.

Also, see https://stackoverflow.com/questions/237664/web-site-vs-asp-net-web-application-in-visual-studio.

Community
  • 1
  • 1
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Yes, John. But this link does not answer my question. Any ideas or comments to my confusion mentioned in my original post? – George2 Jul 03 '09 at 15:33
  • It means that in a project, you can set the root namespace for the project. Pages created in the root of the project will get that namespace. If you create subfolders, then pages created in them, will get the root namespace plus the name of the subfolder, all the way down. You therefore have control over the namespaces that VS will create when you add an item. "No control" does not mean you couldn't manually change the namespaces, though that will screw some things up, as parts of your site will expect no namespace, but you've now created one. Simple answer: don't use web sites. – John Saunders Jul 03 '09 at 17:36