views:

242

answers:

3

To simplify this test case, I created a new default .NET MVC project in Visual Studio 2010, and added the following code to the HTML header in Site.Master:

<script type="text/javascript" src="../../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
  jQuery(document).ready(function () { alert('jQuery document ready'); });
</script>

This works as expected in the .NET development server. However, when deployed to IIS7, the jQuery(document).ready function is not executed. Needless to say, my actual application is much more complicated. This eliminates all "suspects" except IIS7 deployment.

Any thoughts/suggestions?

+1  A: 

Can you confirm that jquery-1.4.1.js is where you think it is? Javascript is run by the browser itself and has nothing to do w/the web-server that is serving that page.

malonso
+1  A: 

The path to your jquery file must be wrong. Can you see it in Firebug (Script tab)?

mmacaulay
Case sensitiveness, maybe? `Scripts` vs `scripts`
Álvaro G. Vicario
IIS does not care about case sensitivity (by default - there may be some way to change this at the server level, but I'm not aware of it, and it seems unlikely in scenario above).
mmacaulay
+1  A: 

It's probably caused by the src reference to

src="../../Scripts/jquery-1.4.1.js"

Replace it with:

src="<%=Url.Content("~/Scripts/jquery-1.4.1.js")%>"

If your site is deployed in a virtual directory this is probably the case.

j3ko
BINGO! That's it. When I looked in the inetpub log file, there was an error on "GET /Scripts/jquery-1.4.1.js" IIS wasn't resolving the relative link properly. Many thanks.
gsiler