Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Build Action in App_Code directory?

Every time I add a new class anywhere underneath my App_Code directory in my MVC 3 web application, it gets set with a Build Action of "Content". I need to set it to "Compile" by default. Is there somewhere in Visual Studio to set a default build action for code underneath this directory?

like image 448
Scott Avatar asked Dec 28 '22 03:12

Scott


1 Answers

MVC projects aren't Website projects, they are Web Application projects. Website projects (unless pre-compiled) are deployed with source code, and are dynamically compiled by the ASP.NET runtime. Web Application projects are built and deployed as separate stages. App_Code is a special ASP.NET folder which is compiled separately from the rest of the application. This is why the items in App_Code default to Content, so they can be deployed (source) separately of the application (which gets compiled).

In Web Application projects, you're not governed by any standard format for your project layout, its all compiled code at the end of the day. I'd recommend either using the Models folder in the project, or just creating your own, I wouldn't use App_Code.

like image 75
Matthew Abbott Avatar answered Jan 18 '23 22:01

Matthew Abbott