gpt4 book ai didi

javascript - asp.net 找不到资源文件

转载 作者:行者123 更新时间:2023-11-30 10:44:26 25 4
gpt4 key购买 nike

我试图在 asp 页面中使用一些自定义脚本和 css 文件。在 Visual Studio 2010 中,我没有收到关于这些文件状态的任何警告或错误,但是当我尝试运行该页面并打开 javascript 控制台时,我收到错误:

Failed to load resource: the server responded with a status of 404 (Not Found)

以下是我尝试将文件加载到我的 ascx 文件中的方式:

<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.scripts.js"></script>
<script type="text/javascript" src="scripts/jquery.alerts.js"></script>
<link href="styles/jquery.alerts.css" rel="stylesheet"/>

谁知道这是怎么回事,为什么浏览器找不到文件但 visual studio 可以?

最佳答案

当 .aspx 文件的位置与用户控件 (ascx) 的位置不同时,就会发生这种情况。

当用户控件在浏览器中呈现时,它实际上将具有 .aspx 的位置并尝试从该点进行引用。而在 VS 中,它将尝试从 .ascx 位置引用文件。

因此,请尝试引用这些文件,就像您从 .aspx 文件位置进行引用一样。它在呈现该页面时不应给您任何错误。

关于javascript - asp.net 找不到资源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9263809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com