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.
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).
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.
I would say , don't use App_Code folder in web application. Please find more details ****here****
Related
I was wondering how to add an app_code folder in console application but could not find that, however I was able to add app_code folder to a website application. Sorry I am newbie don't know much?
app_code folder is in use for ASP.Net Application there is no use of the folder in console application. Could you please explain it clearly why you want to use the folder? For more details you can see link given below.
http://www.bayt.com/en/specialties/q/937/why-do-you-use-the-app_code-folder-in-asp-net/
I've inherited an MVC3 .NET web app, which had all the controllers for the site in a separate project to the main web app. Not sure why this was the case. As it's a small app, I decided (for "neatness") to move the controller code back into the main web project, under the usual "Controllers" folder.
"Controllers" project folders:
Admin
Members
Config
Moved above code into main Web project under "Controllers" folder, ie:
Controllers
Admin
Members
Config
The problem now is, all the links generated by the code include "/Controllers/" in the path, assumedly because the controller code is now in a "Controllers" project folder. Is this a simple MVC issue to fix? Or would it likely be a flaw in code itself, in that it relies on where the code files run from to generate links?
Running under Server08 | IIS7. I have a website project and am in the habit of hand editing the Global.asax.cs at the deployed site many times in the past. Recently I've found that only the Global.asax is present and has only:
<%# Application Codebehind="Global.asax.cs" Inherits="myDomain.MvcApplication" Language="C#" %>
There are simply no Global.asax.cs files present/visible for any of my active, functioning websites anymore.
I've checked here Global.asax can't find code-behind class and here where is the codes in Global.asax in mvc3? without getting anywhere. The second link contains the comment: 'That's because it's a compiled web application. You'll have to view it in Visual Studio as a project.'
But since my project has always been a website - and I've not converted it (intentionally) I'm puzzled by the changed behavior.
But when i step into VS12 and look at the context menu for the solution's WebProject it presents 'Convert to Web Application'. The sites' folder structures do not contain App_Data or App_Start. To my mind, these 2 fact establish at VS is treating the project as a website, why then, is the Global.cs compiled down to the /bin?
I'll close by repeating - I've hand edited these things in the past - I'm not positive but it's probably accurate to say that this is the first time I've tried to do so after installing VS12. And, coming to think on it harder - it's only recently that I've implemented the 'One Click Publishing' service so that could be coming into play.
verify? I'd like I need to edit a simple update without full re-deployment.
thx
I think the 'One Click Publishing' is most likely the culprit here. I created a sample Web Site project to experiment, and when I use the publish feature in Visual Studio, the files generated are indeed missing the Global.asax.cs file. Instead, a bin folder is created with a compilation called "App_global.asax.dll" even though it is a Web Site and not a Web Application. I am guessing this might be similar to what is happening for you as well.
If not, I found a link which might be useful to you in order to once again be able to edit a class on the server. Particularly, have a look at the second answer (the one not accepted as the best answer) to recreate a class file for the global code: Where is the Global.asax.cs file?
I tried this solution, and verified that the class file is editable on the server, and that it is dynamically compiled at run time (the modifications I made to the file worked immediately).
Hope this helps!
After editing the global.asax you need to rebuild and upload the DLL to the bin folder. Otherwise, your changes will not take effect.
You might be able to upload an web version of the global.asax that includes the code in that one file, which obviously does not require a .cs code behind. I used to do it with aspx files in an application but I have never tried it in the GLobal.asax file.
Using VS2010, creating a new MVC 4 Web API project. Just wondering, can the .js-files in the Script folder be deleted, or are they somehow related to the magic beneath? How about those cshtml- files in the Views folder, I can't see that they are necessary for a REST-service, or again, are they part of the underlying technology. My guess, it can all be deleted safely - but just to be sure...
Bonus question (while I'm here): recommendations for unit- and integrationtesting REST-services, got any?
Thank you.
If your project only exposes a series of WebAPI controllers then that implies that your project will never serve actual HTML-based content. Thus, you can safely delete all files related to that content, such as:
HTML files (.cshtml)
JavaScript files (.js)
CSS style sheets (.css)
Images (.jpg, .png, .gif)
This is crazy, but I can't seem to get all my views/content/scripts published when I publish the site. This seems to happen, I believe, when the view or content is not directly referenced by my project, but used by another assembly in my project. So I might have:
ExternalAssembly.dll referenced (it gets published)
I'll need ExternalLogin.cshtml in my main project, under my views folder
ExternalLogin.cshtml doesn't get published
Right now I have a script that copies everything in the Views folder and dumps it to where I want it deployed, but VS should do this for me. What am I doing wrong?
When you click on one if these files what is the build action for it on the properties? Content....or? Set to content.
So your views files are in another project or folder outside your current project? Normally the files have to exist in the web site project, in it's views folder, not externally, and the build action should be set to Content and not to copy to the output folder. But there are some workarounds:
Duplicate them in to your site views folder and make sure they are marked content (as stated in another answer). One thing to note though is that you can add them as "Linked Files" in visual studio which actually allows them to exist in two places in the hierarchy without having to exist in two places on disk: http://support.microsoft.com/kb/306234
If you have control over the external library, you can compile them in as embedded resources or use Razor Generator or something similar and use a custom view engine to return them: How can I make ASP.NET MVC 3 use views (aspx, ascx) files from an external assembly in my website?
Manually put the copies in the .csproj build XML using the Copy task: http://msdn.microsoft.com/en-us/library/3e54c37h.aspx (Note that this will make it work in visual studio doing essentially what you are doing now, as it will then be part of the Visual Studio build if you add it to the AfterBuild target or something)