问题
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:
- Go to https://appharbor.com/your-application.
- Click on Settings.
- Click on Build | DISABLE PRECOMPILATION.
- 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