简体   繁体   中英

Master page “does not exist”

I have an ASP.NET Web forms application. 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.

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. 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'.

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'. 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.

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. This error was fixed by setting the solution platform to x86 (where before it was set to 'Any CPU' for all the projects.). 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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