开发者

Can classes be referenced outside App_Code?

开发者 https://www.devze.com 2023-02-13 06:18 出处:网络
I know this seems pretty basic, but I\'ve been working with MVC for awhile and I\'m not sure what works with asp.ne开发者_StackOverflow中文版t.

I know this seems pretty basic, but I've been working with MVC for awhile and I'm not sure what works with asp.ne开发者_StackOverflow中文版t.

Is it possible to organize code outside the App_Code directory or into separate projects? How would this be done?


Yes, it's possible.

You have a couple choices. One is to use Web Application Projects instead of Web Site projects. WAP's have a LOT more control over where code lives, compilation, etc.

Another is to create a Class Library project and reference this from your existing project. This is a great way to share code amongst multiple projects and/or solutions.

Incidentally, if you are wanting to stick with MVC, then I'd highly suggest you investigate Razor. I've heard nothing but good things about it. Personally, I'm not 100% sold on MVC; but the people I know who are love Razor.


To move code outside of the App_Code folder, you need to place it in a separate class library project, and the dll output from that project must registered in the GAC on your web server (and each of your development machines).

It's this last part that annoys me most, as it's not easy getting all the working with a source control system where the relevant revision that you need installed in the GAC on your local machine may change frequently.

0

精彩评论

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

关注公众号