问题
Can we deploy an asp.net MVC application by copying the source codes only (without compiling them first) like we can do when deploying WebForm website project?
回答1:
No - MVC apps need compilation, like ASP.NET Web Application Projects.
回答2:
Wait... if what you mean is copying the *.aspx and *.ascx files, yes you can, but you have to include the *.dll in the bin folder too.
Copying the *.cs files is useless.
Start by building your application, then select the project (not the solution) that is your StartUp project (the one with the aspx files), then, in the main menu, do Build > Publish Selection and follow the wizard.
回答3:
I'm afraid the answer that has been marked as correct is incorrect.
You can have your controllers inside your App_Code folder. You should follow the naming conventions for your views' folders (~\Views{ControllerName}{ViewName}.cshtml), and simply ensure that your route map correctly wires up the controller. If you do create your controller using the default App_Code behavior, it will not be placed inside a namespace. You should either wrap it in a default namespace ({SiteName}.Controllers) or explicitly set the namespaces: argument to include an empty string for the namespace.
回答4:
Only if the code you are talking about reside in the aspx/ascx files. Most of your code should reside in your middle tier/controller/data tier - so having too much code in the views is usually considered as a bad practice in logic/concern separation.
来源:https://stackoverflow.com/questions/4501649/can-we-deploy-an-asp-net-mvc-application-by-copying-the-source-codes-without-co