ASP.NET MVC 3 and App_Code folder

問題:

In ASP.NET Webform, App_Code is standard folder to putting code and using it at run-time.But I think this folder is kind of different in ASP.NET MVC, my question is:web

  • where should I put my code ( Extension methods , Helpers , ... ) in ASP.NET MVC. When I store code in App_Code folder, I can't use theme in controller but they work fine in views.ide

  • About Entity Framework, the same question, where should I put edmx and tt files. I'm not using Code-Firstthis

Update:spa

After some search, finally I created a new Class Library project in my solution, code is available in allcontrollers and views. I still don't know why the code in App_Code is not available in controller.net

回答 :

App_Code is necessary in Web Site projects because it has a special meaning. It means "Don't serve these files to a web browser". In ASP.NET MVC, files are not directly served to the browser in most cases, so App_Code is not necessary. You can place code files whereever you want, in any folder you want.code

Using a stand-alone library is also a fine solution.orm

原文轉自:http://my.oschina.net/i33/blog/163062blog

相關文章
相關標籤/搜索