开发者

IIS Application + Javascript

开发者 https://www.devze.com 2023-02-11 01:36 出处:网络
So in IIS 7 I created an app called \"Test\" under my regular website: Here is how its setup Site: www.site.com

So in IIS 7 I created an app called "Test" under my regular website:

Here is how its setup

Site: www.site.com App: www.site.com/Test

Now in the Test app I have a masterpage which has the following script tag:

<script 开发者_运维问答type="text/javascript" src="/Assets/Includes/Javascript/jquery-1.4.2.min.js"></script>

When I deployed the site and looked at Firebug its referencing: http://www.site.com/assets/includes/javascript/jquery-1.4.2.min.js

I would like it to reference: http://www.site.com/TEST/assets/includes/javascript/jquery-1.4.2.min.js

What am I doing wrong here? Is this a configuration in IIS7 or should I reference the file differently (I would prefer not to use absolute).

I have deployed applications in virtual directories before under IIS6 and I don't remember having this problem!

Thanking you in advance


If this is ASP.net MVC try:

<script type="text/javascript" src="<%=Url.Content("~/Assets/Includes/Javascript/jquery-1.4.2.min.js")%>"></script>

If this is just ASP.net try adding ~

Example:

<script type="text/javascript" src="~/Assets/Includes/Javascript/jquery-1.4.2.min.js"></script>


Go with Gabe if you are using MVC. Otherwise, you will need to call Page.ResolveUrl to resolve the url because the ~ wont work in <script> tags.

<script type="text/javascript" src='<%= Page.ResolveUrl("~/Assets/Includes/Javascript/jquery-1.4.2.min.js") %>'></script>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号