简体   繁体   中英

ASP.NET Master Page Parse Error

I have a Visual Studio 2010 project with a Master Page that works fine.

~/Site.Master

In the same project is a Folder with another directory structure that needs to use another Master Page.

/xr

Within this folder, I have included the Master Page for those files.

/xr/XR.Master

My Default.aspx file attempts to access this Master Page using the following include:

<%@ Page Title="XR Project" Language="C#" MasterPageFile="~/xr/XR.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test1.Default" %>

Debugging on my machine in localhost works fine, but whenever I deploy it and try to navigate to the Default page in the xr folder, I get

Parser Error Message: The file '/xr/xr/XR.Master' does not exist.

However, the Source Error returns Line 1 as I have shown above.

Here is what I tried:

  • I moved the XR.Master page into the root folder and changed all of the files in the xr folder to reference the XR Master Page using the following include:

  • I debugged and tested the code on my machine using localhost , and it worked fine.

  • I pushed it out to the remote website and got the new error:

Parser Error Message: The file '/xr/~/XR.Master' does not exist.

What am I doing wrong?

EDIT: I do not like posting a link to the page, but I will for a short time until this is resolved:

From there, you will see everything works well enough except for the link to XR1200 .

Here's the best advice I can give ya without knowing too much about your project structure. I'm hoping you are using VS2010 so that things will look the same for you as on my machine. One easy way to get the path of your master page all figured out is to add a test web page from masterfile, the path will be preset for you and you can use that in your existing pages.

  • Here is my blogs project structure. Right click the folder where you want to add the test page and click add new file.
    在此处输入图片说明

  • Add a new web form using Master Page. This is just for testing. 在此处输入图片说明

  • Now locate your Masterpage and select it. 在此处输入图片说明

  • From here just find your newly added content page in your solution structure and check the code files for the path to your masterpage. 在此处输入图片说明

  • Once you've verified that your path is correct, if it still bombs once you publish it then you've got either an issue where not all of your projects are building properly, or you're files aren't being uploaded properly and that is going to end up being something that you may just have to find on your own. I still suggest blowing away anything in your pub folder on your server and trying a clean publish.

Hope this helps!

my guess is that the iis setup is different on the different machines. typically, you see something like this when you have one machine set up with the site itself as a website and another machine set up with the site itself as an application within a website (like the Default Website). it looks like you have addressed this possibility by using the ~ in the path, but perhaps the iis on which you are deploying does not have the site directory itself set up as either a website or an application, but is merely a subdirectory of a site. in that case, the ~ would refer to the website directory (perhaps named xr?) and the site is in a subdirectory of that named xr. if this is the case, the solution is probably to set up iis such that you have the application directory configured as an application on the server to which you are deploying.

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