net -虚拟路径'/Master。master'映射到另一个应用程序,这是不允许的。

时间:2021-09-30 09:24:40

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:

我有一个asp.net母版页位于我的网站的根目录。我有一个从母版页的目录“/myfolder”的页:

 <%@ 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

/主人。主/ 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.

当我将它上传到我的(非专用的godaddy iis 7)服务器上时,为什么会出现这个错误,但是它在本地主机上运行?:解析器错误描述:在解析服务此请求所需的资源时发生错误。请检查以下具体的解析错误细节,并适当修改您的源文件。

Parser Error Message: The file '/timelapserpro/Master.master' does not exist.

解析器错误消息:文件'/timelapserpro/Master。大师”并不存在。

Source Error:

源错误:

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

第1行:<%@页标题="大师”AutoEventWireup = " true "后台代码= " default . aspx。cs myproject的“继承=”。TimelapseDefault " % >

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

第2行: 行3:

All pages are in the same solution.

所有页面都在同一个解决方案中。

2 个解决方案

#1


4  

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

试图改变MasterPageFile = " . . /主人。大师”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

还要检查您是否正确地在iis 7上创建了虚拟文件夹。检查你的应用程序是否正确。在IIS中必须有这样的文件夹结构。

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

#2


3  

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.

您的远程服务器没有设置为web应用程序的文件夹,因此,当您用“~”引用它时,它将查看应用程序的根,它恰好是服务器根。

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

但是,在您的本地机器上,'/timelapserpro/是一个完整的应用程序,所以~/引用'/timelapserpro,而不是'/'。

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.

您需要在本地服务器上降级您的应用程序,这样它就不再是自己的应用程序了,或者将目标服务器文件夹提升为一个应用程序以使两者同步。

#1


4  

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

试图改变MasterPageFile = " . . /主人。大师”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

还要检查您是否正确地在iis 7上创建了虚拟文件夹。检查你的应用程序是否正确。在IIS中必须有这样的文件夹结构。

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

#2


3  

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.

您的远程服务器没有设置为web应用程序的文件夹,因此,当您用“~”引用它时,它将查看应用程序的根,它恰好是服务器根。

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

但是,在您的本地机器上,'/timelapserpro/是一个完整的应用程序,所以~/引用'/timelapserpro,而不是'/'。

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.

您需要在本地服务器上降级您的应用程序,这样它就不再是自己的应用程序了,或者将目标服务器文件夹提升为一个应用程序以使两者同步。