Error: “The file '/MasterPages/MainMaster.master' does not exist.” (Yes, this file does exist!)

爷,独闯天下 提交于 2019-12-05 00:37:08

问题


I just got a new desktop computer with Windows 7 Pro as the operating system. I installed Visual Studio 2008 on to this new computer and tried to open a previously existing ASP.NET 3.5 solution that displayed perfectly fine on my previous computer (this previous computer used the Windows XP operating system, IIS6, and IE7 browser). However, in Windows7/IE8, I’m receiving the following error:

Server Error in '/' Application.


Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The file '/MasterPages/MainMaster.master' does not exist.

Source Error:

Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_Default" MasterPageFile="~/MasterPages/MainMaster.master"%> Line 2:
Line 3: <%@ Register TagPrefix="SBLContent" TagName="SBLContentBlock" Src="usercontrols/content.ascx"%>

Source File: /SBLWebSite/default.aspx Line: 1


Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4927

Please believe me when I tell you that the file ‘/MasterPages/MainMaster.master’ file does, in fact, exist.

In addition, this file’s location is properly referenced in the code (as indicated in Line 1 above), and as I said, was displayed properly by the browser in my previous computer. It might also be helpful to note that I’ve tried to navigate to other pages in this site, and this browser displays the same message for any and all master pages located in my MasterPages folder.

In summary, for some reason the browser cannot see any pages in the MasterPages folder. Can anybody tell me why I’m getting this error message when the folder and file is exactly where default.aspx says it is?

Thanks in advance!


回答1:


I appreciate your response.

However, this issue turned out to be an IIS7 issue. The error message I described arose out of the distinction made in IIS7 between a "virtual directory" and an "application" (I don't know if such a distinction existed in IIS6). To fix this error, I opened IIS7, right-clicked on the virtual directory folder for this site, and selected "Convert to Application." I then refreshed the browser, and the error went away.

Sigh.




回答2:


Two things to check:

  1. When using "~" in a file path, make sure that the current application deployment believes the root directory is the same as it was before. (I've run into this sometimes moving an app from the VS Development Server and IIS.)

  2. Make sure that the user account that the server is running under has permissions to access that directory. Since you just moved the code over from another computer and probably some intermediate storage devices, the security permissions may not be right.




回答3:


Instead of the "~" I was able to simply change the directory to a relative ".." So, what I originally had that gave me the problem was something like: "~/MasterPage/TheMainMasterPage.master" and this caused me to get the same error message. Changing it to "../MasterPage/TheMainMasterPage.master" fixed everything for me.




回答4:


I recently had to move my websites from one server(32 bit) to another server(64 bit). On the new server I experienced the file not found error "Parser Error Message: The file '~/Master.master' does not exist"

NB: some of my applications were built for x86, you still need to convert your website to an application :-)

Solution: In IIS8, click Application Pool -> select an app pool eg DefaultAppPool -> click 'Advanced Settings' -> Under the 'General' section set 'Enable 32-Bit Applications' to 'True' -> Click OK

Refresh your website/webservice and that should do the trick




回答5:


the error comes on the web form like this

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="add_drivers.aspx.vb" Inherits="au_transport.WebForm1" %>

correction

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="Site1.Master" CodeBehind="add_drivers.aspx.vb" Inherits="au_transport.WebForm1" %>



来源:https://stackoverflow.com/questions/3825498/error-the-file-masterpages-mainmaster-master-does-not-exist-yes-this-fi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!