9

I've just started using a cms (N2) which has a template basic implementation using a web site project template in vs2008. I've noticed that when compiling it it takes a lot longer than using a web application project which I am more use to.

My questions are:

  1. Why does it seem to take a lot longer to compile?
  2. Which is better to use?
  3. Should I convert it into being a web application?

I apologise if this is a duplicate but I couldn't find a similar question.

Cheers

WestDiscGolf
  • 4,096
  • 2
  • 32
  • 47
  • Have a look at this question: http://stackoverflow.com/questions/475938/what-is-the-difference-between-web-application-and-website-in-asp-net – M4N Feb 11 '09 at 22:16
  • No, just been busy at work recently and not had any tidy up on SO time ... all done now :-) – WestDiscGolf Feb 25 '09 at 08:50
  • possible duplicate of [ASP.NET Web Site or ASP.NET Web Application?](http://stackoverflow.com/questions/398037/asp-net-web-site-or-asp-net-web-application) – John Saunders Jun 04 '13 at 00:40

3 Answers3

10

The Major differences are:

In a Web Application project everything is pre-compiled all the codebehind pages will be compiled into a .dll ---- In a Web Site Project nothing in the project is pre-compiled, the compiler will compile everything to ensure it is valid but none of the compiled pages are uploaded. When a user first attempts to access the site each page is compiled into its own dll. This means in a Web Site Project you are able to upload a single codebehind file.

Namespaces - In a Web Application project namespaces are created by default in a Web Site Project they are not.

Project files - A Website Project does not have a "cproj" file a Web Application project does.

Converting to a Web Application project can be more difficult then you think especially if you rely heavily the appcode folder.

I personally prefer a Web Application projects I find them easier to use and less annoying to deploy. I would personally only use web site project on something very small and simple.

Extra reading from MSDN

cgreeno
  • 29,714
  • 7
  • 64
  • 85
  • You can compile a Web Site Project as well so that all code behind and App_Code gets compiled into dlls and all the aspx pages are just stubs. They do not however get compiled into a single dll like a web application does. – dtc Feb 12 '09 at 01:33
  • Yes you can but, and I may be wrong, you need to use msbuild and you are only trading the page .cs file for page.dll. I dont think it gains you much other then quicker first time startup – cgreeno Feb 12 '09 at 13:35
  • +1 Thanks for the summary :-) I'm with you on the preferring the web application project route. The decision now is to convert now or later ;-) – WestDiscGolf Feb 13 '09 at 08:58
  • Actually you can get all your compiled code into one dll by using the aspnet_merge.exe command. This is an old article about managing your dll's with using the aspnet compiler, but its still just as relevant: http://msdn.microsoft.com/en-us/library/aa479044.aspx – Pauli Østerø Oct 04 '10 at 17:27
1

My preference is to use Website project over web application. I mainly rely on "View in Browser" to execute the page during development and not f5. I can leave the browser window open and modify code without closing the runtime browser. Usually if I need to debug I attach the IDE to the appropriate process. In my experience it much more efficient to do it this way instead of compile and restarting the app everytime I have to compile or make changes. This is magnified even more if the app has a login page. Need for logging in is avoided everytime F5 is pressed - granted there are ways to set it up. But preference is not to.

KN.
  • 11
  • 1
  • +1 Valid point and I use that on the websites that I work on. Interestingly enough this is also how you can work with asp.net mvc application projects; build > hit refresh, no f5 in the IDE required. It does just depend on what you are writing and what you are trying to achieve :-) – WestDiscGolf Apr 15 '10 at 12:03
1

In addition to the info provided by Chris, you should also note that for Web Application Projects, Profiles are not available out of the box:

http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx

There is a workaround available here: http://code.msdn.microsoft.com/WebProfileBuilder

Basically, the Web Application Project does not have the Profile object automatically added to each page as with the Web Site project, so we cannot get strongly-typed programmatic access to the profile properties defined in our web.config file.

Anthony :-)

IrishChieftain
  • 15,072
  • 7
  • 47
  • 90