ASP.net - The virtual path '/Master.master' maps to another application, which is not allowed

江枫思渺然 提交于 2019-12-11 00:48:13

问题


I have an asp.net master page located in the root directory of my site. I have a page in the directory "/myfolder" from the master page:

 <%@ Page Title="" Language="C#" MasterPageFile="../Master.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myproject.TimelapseDefault" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 <p>

The files look like:

/Master.master /myfolder/default.aspx

Why do I get this error, when I upload it to my (non dedicated godaddy iis 7) server, but it works on localhost?: 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 '/timelapserpro/Master.master' does not exist.

Source Error:

Line 1: <%@ Page Title="" Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myproject.TimelapseDefault" %>

Line 2: <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
Line 3: <p>

All pages are in the same solution.


回答1:


try to change MasterPageFile="../Master.master" to MasterPageFile="~/Master.master"

Also check if you create virtual folder on your iis 7 properly. Check if path to your app is correct. You have to have such folder structure in your IIS

->YourAppName (the root of your app contains your root files)
  ->myfolder (contains your myfolder content)



回答2:


Your remote server doesn't have the folder set up as a web application, so when you refer to it with "~", it is looking in the root of the application which happens to be the server root.

BUT, on your local machine, '/timelapserpro/is a full application so ~/ refers to '/timelapserpro, not '/'.

You need to either demote your application on the local server so it isn't it's own app anymore, or to promote the destination server folder to be an application to get the two to sync up.



来源:https://stackoverflow.com/questions/12271205/asp-net-the-virtual-path-master-master-maps-to-another-application-which-i

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