简体   繁体   English

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

[英]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.

相关问题 为什么 SharePoint 远程事件接收器为我们托管在 azure Web 应用程序中的 .SVC 引用错误的 url - Why SharePoint remote event receiver is referencing wrong url for our .SVC hosted inside azure web app iis托管的网站与本地网站不同 - iis hosted web site differs from local web site 从网站上托管的视频中提取图像 - Extract an image from a video hosted on a web site 如何在IIS中本地托管的应用程序的URL中添加自定义目录? - How to add custom directory in URL for app hosted locally on IIS? 如何将网站从IIS托管站点更改为ASP.Net Development Server托管站点? - How do I change a web site from an IIS hosted site to an ASP.Net Development Server hosted site? 使用Windows身份验证站点中托管的Web服务配置匿名访问 - Configure a web service w/ Anonymous Access hosted in a Windows Authentication site 为使用Url重写的实时网站进行本地开发 - Developing Locally for a site that, when live, utilises Url Rewriting 从SSIS包转向IIS上托管的网站 - Turn of web site hosted on IIS from SSIS package 我在IIS服务器中本地托管的asp.net C#网站给出错误 - my locally hosted asp.net C# site in IIS server is giving error 错误尝试访问网络服务(本地或外部托管),无法解析主机名 - Error attempting to access a web service (hosted locally or externally), can't resolve host name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM