发布 ASP.Net MVC 应用程序时是否应该部署 cs 文件?
我有一个项目可以在我的开发机器上编译并运行良好,但是当我在 Web 服务器上运行它时,出现以下错误。
解析器错误消息:文件“/Views/Shared/Main.master.cs”不存在。
服务器上不存在提到的文件,但文件“/Views/Shared/Main.master”存在。
我使用“发布”命令上传项目。 是不是缺少cs文件?
是否有一些设置只需要关闭实时编译?
I have a project that compiles and runs fine on my development machine but when I run it on the web server I get the following error.
Parser Error Message: The file '/Views/Shared/Main.master.cs' does not exist.
The file mentioned does not exist on the server but the file '/Views/Shared/Main.master' does.
I use the 'Publish' command to upload the project. Is it missing the cs files?
Is there some setting where it does just in-time compiling that need to turn off?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我偶然发现了这个解决方案。
母版页具有以下属性
CodeFile="Main.master.cs"
。 当我用CodeBehind="Main.master.cs"
替换它时,它按预期工作。该文件最初来自较旧的网络应用程序,但我不知道其中的区别是什么。 如果其他人能提出更好的解释,我会接受他们的答案而不是这个。
I stumbled upon this solution.
The master page has the following attribute
CodeFile="Main.master.cs"
. When I replaced this withCodeBehind="Main.master.cs"
it works as expected.The file originally came from an older web application but I don't know what the difference means. If someone else can come up with a better explanation I will accept their answer instead of this one.
很高兴你明白了。 这可能是由于从“网站”项目类型转换为“Web 应用程序”项目类型时出现的问题。
http://aspadvice.com/blogs/ ssmith/archive/2007/01/24/CodeFile-or-CodeBehind.aspx
Glad you got it figured out. It may come from an issue when converting from "Web Site" to "Web Application" project type.
http://aspadvice.com/blogs/ssmith/archive/2007/01/24/CodeFile-or-CodeBehind.aspx
通常,这些文件都标记有对 bin 中存在的 dll 的引用,例如 Main.master 的继承声明中的 App_Web_nnnnn。 Web 服务器上的该文件是否属于这种情况?引用的 dll 是否存在于 bin 中? 如果没有,那么它可能没有按应有的方式进行预编译。
Usually the files are marked with a reference to a dll that exists in the bin, e.g. App_Web_nnnnn in the inherits declaration of Main.master. Is that the case for that file on the web server and does the referenced dll exist in the bin? If not then it may not be pre-compiling as it should.
据我所见的 MVC,我认为您甚至不需要代码隐藏页面,是吗?
我已从我的应用程序中出于任何原因存在的任何页面中删除了引用。
另外,当您创建一个新视图时,我认为它甚至不会在 MVC 中创建代码隐藏页面,不是吗? (一开始真的让我很震惊!!)
As far as I have seen with MVC, I don't think you even need the code-behind pages, do you?
I have removed the references from any pages in my app that were there for any reason.
Also, when you create a new View, I don't think it even creates the code-behind page in MVC, does it? (Really threw me to start with!!)