.js files not being located by website on Win 2008 Web Edit IIS 7

I have been going around in circles with this for a couple of days now. I usually find what I need without posting.

I have a pretty simple one page website written in asp.net with a c# back end. I have a javascript carousel. My problem is that everything is fully functional in my dev environment (Macbook Pro, Bootcamp Vista, VS 2008).

When I deploy to my dedicated server (Windows 2008 Web Edition IIS7) (first time for me!) I have followed all the advise. I have bound the website to IP. I have ensured that I have an authenticated anonymous user and IIS user.

So I looked at how I was addressing the .js files. I have 3.

<script language="javascript" src="<%=ResolveUrl("Scripts/jquery.min.js")%>" type="text/javascript"></script>
<script language="javascript" src="<%=ResolveUrl("Scripts/jquery.easing.1.3.js")%>" type="text/javascript"></script>
<script language="javascript" src="<%=ResolveUrl("Scripts/slides.min.jquery.js")%>" type="text/javascript"></script>

For the life of me it does not seem as though they are being addressed correctly. I can grab jquery.min.js from <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> and it works partially. All script from the files I address on my server fail.

I tried to debug the javascript too ... I got

SCRIPT5009: '$' is undefined

Now my guess is that it is not defined because the site is not addressing the .js file that has the corresponding code.

If anyone has an idea on this ... or has encountered it before, please do help.

Thank you

* EDIT *

Okay I have this in the HTML

<script language="javascript" src="<%=ResolveUrl("~/Scripts/jquery.min.js")%>" type="text/javascript"></script>
<script language="javascript" src="<%=ResolveUrl("~/Scripts/jquery.easing.1.3.js")%>" type="text/javascript"></script>
<script language="javascript" src="<%=ResolveUrl("~/Scripts/slides.min.jquery.js")%>" type="text/javascript"></script>

When I view page source I have this

<script language="javascript" src="/Scripts/jquery.min.js" type="text/javascript"></script>
<script language="javascript" src="/Scripts/jquery.easing.1.3.js" type="text/javascript"></script>
<script language="javascript" src="/Scripts/slides.min.jquery.js" type="text/javascript"></script>

In fiddler I have this

404 - File or directory not found

Answers


You need to put a forward slash after the tilde:

ResolveUrl("~/Scripts/slides.min.jquery.js")

Okay ... this is resolved. What can I say ... it is a little like hitting your head on a kitchen cupboard door. It has been there for years and you use it everyday ... but once in a while you crack your head on it enough to make your eyes water ...

My problem was 2 fold - 1:

When I created my directory in IIS for my new site, I created WebsiteFolder/wwwroot. This was a school boy error. I placed my website into the wwwroot folder. Of course when I addressed anything in the site with ~/ it went to the top of the directory hierarchy. Thus when it then tried to look for ~/Scripts/.... it could not find them (because they were in ~/wwwroot/Scripts...). So I deleted the website and deleted the directory. Recreated the directory WebsiteFolder and applied the user accounts needed. I then bound a newly created site to the new directory.

My second problem was that I added one of the .js files by adding existing item from another site. I am not sure how, but this file had ghosting permissions which meant that my call did not have the correct authorisation for access. I copied the contents, deleted the file and recreated from new. Pasted code and recompiled and publish.

This is my first time in doing this and I have fallen into a noob bear trap. I just hope that this answer assists someone like me :)

Kudos to Michal Klouda who told about Fiddler, with out this application I would never have seen what was going on and establish the cause of my problem. Thanks.


You should write you statement as

<script src='<%=Page.ResolveUrl("Scripts/jquery-1.7.1.min.js")%>' type="text/javascript"></script>

assuming your .aspx are on root folder.

like

Default.aspx

Scripts/jquery-1.7.1.min.js


Need Your Help

Can I use code to load a stream of my choosing into an assembly's manifestresourcestream?

c#

I'm calling a library in a separate appdomain (this library has a memory leak and this was the way I solved it). The library has an option to either specify the manifest resource name for the file...

Why override operator()?

c++ boost operator-overloading functor function-call-operator

In the Boost Signals library, they are overloading the () operator.

How to pass variable from form submit function to page callback function in Drupal 6

drupal drupal-6 drupal-modules

I have a Drupal form and a submit function that processes that form. I would like to pass data from the submit function to the page callback function that loads after the form was processed.