简体   繁体   English

母版页“不存在”

[英]Master page “does not exist”

I have an ASP.NET Web forms application. 我有一个ASP.NET Web窗体应用程序。 I have performed a precompiled build and loaded the files onto my server. 我已经执行了预编译的构建并将文件加载到我的服务器上。 However the application throws this error to the browser: 但是,应用程序向浏览器抛出此错误:

The file '/myapp.master' does not exist. 文件“ /myapp.master”不存在。

This error is confusing to me. 这个错误令我感到困惑。 Since I have performed a precompiled build, I would expect that the code for the master page to exist only as compiled code in the bin folder. 由于我已经执行了预编译的构建,因此我希望母版页的代码仅作为已编译的代码存在于bin文件夹中。 But yet it seems to be looking for a physical file? 但是它似乎正在寻找物理文件吗? Why might that be? 为什么会这样呢?

The first line in my master page is as follows: 我的主页的第一行如下:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="myapp.master.cs" Inherits="PresentationLayer_myapp" %>

If you have got this error before, what fixed it for you? 如果以前有此错误,那么什么可以解决呢?

You need to make sure the virtual directory is an application - not just a virtual directory. 您需要确保虚拟目录是一个应用程序-不仅仅是虚拟目录。 In IIS, right click on the virtual directory and select 'Convert to Application'. 在IIS中,右键单击虚拟目录,然后选择“转换为应用程序”。

It appears this error with the Master page was not the real problem. 似乎“母版页”错误不是真正的问题。

Since the error was reporting a problem with the Master page not existing, when publishing the website via VS2010 I selected the option 'Allow this precompiled site to be updatable'. 由于错误报告的是母版页不存在的问题,因此在通过VS2010发布网站时,我选择了“允许此预编译网站可更新”选项。 I knew this option would produce an ASPX Master page, whereas if I did not select this, the ASPX would be precompiled and would exist only in the /bin folder as compiled code. 我知道此选项将产生一个ASPX母版页,而如果我不选择它,则ASPX将被预编译,并且仅作为编译代码存在于/ bin文件夹中。

So when the application was deployed, on attempting to access the application it no longer reported an issue with the Master page, it now reported a BadImageFormatException with one of my DLL's. 因此,在部署应用程序时,在尝试访问该应用程序时,它不再报告母版页问题,现在它报告了BadDLLFormatFormatException,其中包含我的DLL之一。 This error was fixed by setting the solution platform to x86 (where before it was set to 'Any CPU' for all the projects.). 通过将解决方案平台设置为x86(之前将所有项目都设置为“任何CPU”的位置)可以解决此错误。 To do this, go to the toolbar in Visual Studio, and click Build -> Configuration Manager , and from there you can modify the Platform setting for each project in your solution. 为此,请转到Visual Studio中的工具栏,然后单击Build-> Configuration Manager,然后您可以在其中修改解决方案中每个项目的Platform设置。

Once I had done this, I was able to publish a fully precompiled build this time, and it no longer reported any problem with the Master page. 完成此操作后,这次便可以发布完全预编译的内部版本,并且不再报告“母版”页面有任何问题。

I'm still not sure why it was reporting an error with the Master page beforehand, but I would suspect that perhaps the issue with the DLL was causing the compiled code to mess up, and since the Master page is the first thing to be loaded when making a request to the homepage of the website, then it was this page which was mentioned on the error page. 我仍然不确定为什么它事先会报告“母版页”错误,但是我怀疑DLL的问题可能导致编译后的代码混乱,并且因为“母版页”是要加载的第一件事当向网站首页提出请求时,错误页面上就是该页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM