英文:
Error 404: when rendering jquery-1.4.1.min.js from Script folder
问题
-
网站:https://abc.xyz.com/emrsso
-
IIS 设置:站点 > SHC > EMRSSO
-
虚拟路径:/EMRSSO
-
默认文档:SSOLogin.aspx
-
物理路径:D:\Renesan\SHCTest\EMRSSO
还有一个位于 EMRSSO 下的 Scripts 文件夹,例如 D:\Renesan\SHCTest\EMRSSO\Scripts。
然后在 Scripts 文件夹下有 jquery-3.4.1.min.js,例如 D:\Renesan\SHCTest\EMRSSO\Scripts\jquery-3.4.1.min.js。
当我访问 https://abc.xyz.com/emrsso 时,出现 404 错误或者 jquery-3.4.1.min.js 无法加载,在 Chrome 开发工具中调试时,路径显示为 'https://abc.xyz.com/Scripts/jquery-3.4.1.min.js' 而不是 'https://abc.xyz.com/emrsso/Scripts/jquery-3.4.1.min.js'。
当我访问 https://abc.xyz.com/emrsso/SSOLogin.aspx 时,jquery-3.4.1.min.js 能够成功加载,在 Chrome 开发工具中调试时,路径显示为 'https://abc.xyz.com/emrsso/Scripts/jquery-3.4.1.min.js',这是正确的。
当我通过 Visual Studio 调试我的应用时,jquery-3.4.1.min.js 能够成功加载并正常工作。
SSOLogin.aspx 中的 ASPX 代码:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SSOLogin.aspx.vb" Inherits="EHR_Web.SSOLogin" %>
<script src="https://global.oktacdn.com/okta-signin-widget/5.2.0/js/okta-sign-in.min.js" type="text/javascript"></script>
<link href="https://global.oktacdn.com/okta-signin-widget/5.2.0/css/okta-sign-in.min.css" type="text/css" rel="stylesheet" />
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
然而,我没有找到解决方法。这里可能出了什么问题?
英文:
-
Website: https://abc.xyz.com/emrsso
-
IIS Setup: Site > SHC > EMRSSO
-
Virtual Path: /EMRSSO
-
Default Document: SSOLogin.aspx
-
Physical path: D:\Renesan\SHCTest\EMRSSO
And also there is Scripts folder under EMRSSO e.g. D:\Renesan\SHCTest\EMRSSO\Scripts.
Then there is jquery-3.4.1.min.js under Scripts folder e.g. D:\Renesan\SHCTest\EMRSSO\Scripts\jquery-3.4.1.min.js
when I visit https://abc.xyz.com/emrsso, It is 404 error or jquery-3.4.1.min.js, on debugging I found in chrome dev tool path is showing as
'https://abc.xyz.com/Scripts/jquery-3.4.1.min.js' instead of 'https://abc.xyz.com/emrsso/Scripts/jquery-3.4.1.min.js'
when I visit https://abc.xyz.com/emrsso/SSOLogin.aspx, jquery-3.4.1.min.js is rendering successfully and on debugging in chrome dev tool path is showing as
'https://abc.xyz.com/emrsso/Scripts/jquery-3.4.1.min.js' which is fine.
When I debug my application through Visual Studio jquery-3.4.1.min.js is rendering successfully and working fine.
ASPX Code for jquery-3.4.1.min.js:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SSOLogin.aspx.vb" Inherits="EHR_Web.SSOLogin" %>
<script src="https://global.oktacdn.com/okta-signin-widget/5.2.0/js/okta-sign-in.min.js" type="text/javascript"></script>
<link href="https://global.oktacdn.com/okta-signin-widget/5.2.0/css/okta-sign-in.min.css" type="text/css" rel="stylesheet" />
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
I have gone through other question:
https://stackoverflow.com/questions/37556913/why-iis-doesnt-handle-relative-path-the-same-way-iis-express-does
However I did not find any resolution. what can be wrong here?
答案1
得分: 1
尝试解析您的URL,这将使路径保持一致,无论页面/控件位于哪个文件夹中。
<script src="<%=ResolveUrl("~/Scripts/jquery-1.4.1.min.js")%>" type="text/javascript"></script>
有关详细信息,请访问:https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.control.resolveurl?view=netframework-4.8.1
英文:
Try resolving your URL, this keeps the path consistent regardless of which folder a page/control is in.
<script src="<%=ResolveUrl("~/Scripts/jquery-1.4.1.min.js")%>" type="text/javascript"></script>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论