发布 ASP.Net MVC 应用程序时是否应该部署 cs 文件?

发布于 2024-07-11 20:04:21 字数 265 浏览 5 评论 0原文

我有一个项目可以在我的开发机器上编译并运行良好,但是当我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

书信已泛黄 2024-07-18 20:04:21

我偶然发现了这个解决方案。

母版页具有以下属性 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 with CodeBehind="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.

春庭雪 2024-07-18 20:04:21

很高兴你明白了。 这可能是由于从“网站”项目类型转换为“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

强辩 2024-07-18 20:04:21

通常,这些文件都标记有对 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.

離殇 2024-07-18 20:04:21

据我所见的 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!!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文