开发者

Default Build Action in App_Code directory?

开发者 https://www.devze.com 2023-02-02 11:12 出处:网络
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

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 Studi开发者_Python百科o to set a default build action for code underneath this directory?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消