views:

1191

answers:

2

How come App_Code is not a choices in the Add ASP.NET Folder submenu in the VS solution explorer? I realize you can create one yourself manually by just renaming a New Folder, but what is the rational here? Is this not where you are supposed to put "utility" or "service layer" type classes?

On a MVC project side note. I do like the fact that there is a reference to System.Configuration out-of-the-box unlike the default ASP.NET Web Form Projects.

+3  A: 

Generally, I place "service layer" and "utility" classes in a separate project and add it as a reference to my web application. With the MVC framework, I don't really see a need to compile classes at runtime.

David Brown
+6  A: 

This is probably because an ASP.NET MVC project is a web application rather than a web site. In a web site, class files are compiled dynamically at run-time and must live in the App_Code folder. In a web application, everything is compiled statically and class files can live anywhere in your web application.

As David Brown pointed out, it's generally recommended to put extra class definition in a separate class library and then reference that from your web application. If you write unit tests or reference your classes from config files, it can be challenging or impossible to access these classes if they are defined only within your web application.

davogones
+1. I also noticed the is a "Convert to Web Application" what is that about? why is it an option in MVC?
tyndall
+1 for explaining it better than I did. ;)
David Brown
Ironically, "Convert to Web Application" is only available for web applications! This option is really for web applications that were converted from web sites. This goes through all of your aspx and ascx files and converts them to web application format.
davogones
davogones, any thoughts on this one: http://stackoverflow.com/questions/425015/asp-net-wcf-and-could-not-load-file-or-assembly-appwebhamznvwf I have been wrapped up on a few other things and haven't been able to call Microsoft yet
tyndall