How to use ASP.NET MVC view precompilation with App_Code helpers?

荒凉一梦 提交于 2019-12-14 03:46:23

问题


I am trying to enable view compilation to have my ASP.NET MVC3 web site load faster. My web site is hosted on AppHarbor.

However, my views make use of MVC3 view helpers, defined in the App_Code folder.

When I try to load my web-site, I get: "The directory '/App_Code/' is not allowed because the application is precompiled."

How can I stop the App_Code folder being deployed to the web-server, but still have the App_Code helpers pre-compiled?

I've tried changing the helpers to Content=None, but this leads to an AppHarbor build error because the helper files cannot be found during pre-compilation.


回答1:


Old question, but I just got that problem, and the following procedure has worked for me:

  1. Go to https://appharbor.com/your-application.
  2. Click on Settings.
  3. Click on Build | DISABLE PRECOMPILATION.
  4. Force appharbor to do a rebuild/redeploy (by pushing a new commit to the repository).



回答2:


I have just deleted my shared helpers and deleted the App_Code folder because of this problem. I have changed my project to use partial views instead .

According to this answer helpers must be in the App_Code folder but this won't work using AppHarbor.




回答3:


I would say , don't use App_Code folder in web application. Please find more details ****here****



来源:https://stackoverflow.com/questions/13120823/how-to-use-asp-net-mvc-view-precompilation-with-app-code-helpers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!