ASP.NET MVC相对于JavaScript的路径

时间:2021-04-21 04:09:30

I am trying to reference the jQuery library in my master page like so:

我试图在我的母版页中引用jQuery库,如下所示:

src="<%= ResolveUrl("~/Scripts/jquery-1.2.6.js")%>" type="text/javascript">

The source for the page shows:

该页面的来源显示:

<script src="/DocumentManagement/Scripts/jquery-1.2.6.js"  type="text/javascript"></script>

which seems to be correct since my site's url is http://servername/documentmanagement.

这似乎是正确的,因为我的网站的网址是http:// servername / documentmanagement。

However I am getting errors in the javascript functions indicating that the jQuery library is not found e.g. 'Object expected'.

但是我在javascript函数中遇到错误,表明找不到jQuery库,例如'对象预期'。

The same code works fine on my dev(XP - ASP.Net dev server) machine but not on a Win2003 box (IIS). What am I doing wrong?

相同的代码在我的开发(XP - ASP.Net开发服务器)机器上工作正常,但在Win2003机器(IIS)上没有。我究竟做错了什么?

3 个解决方案

#1


Have you checked the logs to see if the request is being made and what type of response it is getting? The URL looks correct, so I'd suspect some configuration or permissions issue.

您是否检查了日志以查看是否正在进行请求以及获取的响应类型? URL看起来正确,所以我怀疑一些配置或权限问题。

#2


You could load up firebug to get some help, and see if it's a problem on the client side. It will also help by getting any server responses (404, 403, etc.)

您可以加载firebug以获得一些帮助,并查看它是否是客户端的问题。获取任何服务器响应也会有所帮助(404,403等)

#3


Apologies for wasting your time! The jquery reference was using the wrong version number!!! Brainfart!

抱歉浪费你的时间! jquery引用使用了错误的版本号! Brainfart!

#1


Have you checked the logs to see if the request is being made and what type of response it is getting? The URL looks correct, so I'd suspect some configuration or permissions issue.

您是否检查了日志以查看是否正在进行请求以及获取的响应类型? URL看起来正确,所以我怀疑一些配置或权限问题。

#2


You could load up firebug to get some help, and see if it's a problem on the client side. It will also help by getting any server responses (404, 403, etc.)

您可以加载firebug以获得一些帮助,并查看它是否是客户端的问题。获取任何服务器响应也会有所帮助(404,403等)

#3


Apologies for wasting your time! The jquery reference was using the wrong version number!!! Brainfart!

抱歉浪费你的时间! jquery引用使用了错误的版本号! Brainfart!