网站重定向到本地托管的错误网址

时间:2013-12-23 08:42:56

标签: asp.net localhost web-hosting

我在http://localhost/托管的网站上遇到以下问题,该网站以前托管在visual studio上。我在rool文件夹中创建了文件夹名称website4并移动了网站。

然后我收到了以下错误。

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 virtual path '/assets/masters/homepage.master' maps to another application, which is not allowed.

Source Error: 


Line 1:  <%@ Page Language="C#" MasterPageFile="/assets/masters/homepage.master" Title="Content Page 1" %>
Line 2:  
Line 3:  <asp:Content ContentPlaceHolderID="Extra_dNet_Code" Runat="Server">

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

然后我将上面的url('/assets/masters/homepage.master')更改为以下('〜/ assets / masters / homepage.master')。 之后我收到以下错误

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 virtual path '/assets/stylesheets/css.ascx' maps to another application, which is not allowed.

Source Error: 


Line 1:  <%@ Master Language="C#" %>
Line 2:  <%@ Register Src="/assets/stylesheets/css.ascx" TagName="css" TagPrefix="include" %>
Line 3:  <%@ Register Src="/assets/javascripts/scripts.ascx" TagName="scripts" TagPrefix="include" %>
Line 4:  <%@ Register Src="/assets/header/header.ascx" TagName="header" TagPrefix="include" %>

Source File: /WebSite4/assets/masters/homepage.master    Line: 2

然后我将上面的网址更改为以下

<%@ Register Src="~/assets/stylesheets/css.ascx" TagName="css" TagPrefix="include" %>
<%@ Register Src="~/assets/javascripts/scripts.ascx" TagName="scripts" TagPrefix="include" %>
<%@ Register Src="~/assets/header/header.ascx" TagName="header" TagPrefix="include" %>

然而,它开始在没有javascript和css的网站上运行。 当我点击图片时,它总是在没有website4的网址之后重定向网站。类似这个网址的东西

`http://localhost/assets/images/...`

上面的链接应该是

http://localhost/website4/assets/images/...

或者只是重定向到http://localhost.

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

尝试指定您的MasterPage相对网址,如下所示:

<%@ Page Language="C#" MasterPageFile="~/assets/masters/homepage.master"  .. %>
<%@ MasterType VirtualPath="~/assets/masters/homepage.master" %>

请注意,当您执行~/时,asp.net会查找root/assets/masters/homepage.master

不要只使用正斜杠,请将其与〜~/

一起使用