[英]web site is redircting to wrong url hosted in locally
I was having the following issue with the web site I hosted on http://localhost/
which was previously hosted on visual studio. 我在
http://localhost/
上托管的网站遇到了以下问题,该网站以前在Visual Studio中托管。 I have created folder name website4 in the rool folder and move the website. 我已经在rool文件夹中创建了文件夹名称website4,并移动了该网站。
Then I got following error. 然后我得到以下错误。
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
Then I changed the above url ('/assets/masters/homepage.master') to following ('~/assets/masters/homepage.master'). 然后,我将上述网址('/assets/masters/homepage.master')更改为以下网址('〜/ assets / masters / homepage.master')。 After that I got the following error
之后,我得到以下错误
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
Then I changed the above url to following 然后我将上面的URL更改为以下
<%@ 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" %>
However it started to work the site without javascript and css. 但是,它开始在没有javascript和CSS的情况下可以正常工作。 When I click images it always redirect the site following urls without website4.
当我单击图像时,它总是在不使用website4的情况下按照网址重定向该网站。 Somthing similar like this url
类似这样的网址
`http://localhost/assets/images/...`
Above link should be 上面的链接应该是
http://localhost/website4/assets/images/...
Or it just redirect to http://localhost.
或者它只是重定向到
http://localhost.
How to fix that issue? 如何解决这个问题?
try specifying your MasterPage
relative url like below: 尝试指定您的
MasterPage
相对网址,如下所示:
<%@ Page Language="C#" MasterPageFile="~/assets/masters/homepage.master" .. %>
<%@ MasterType VirtualPath="~/assets/masters/homepage.master" %>
Note that, when you do ~/
, asp.net will look for root/assets/masters/homepage.master
请注意,当您执行
~/
,asp.net将查找root/assets/masters/homepage.master
do not use just the forward slash, use it with ~ ie ~/
不要只使用正斜杠,而是将其与〜即
~/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.