SoftwareSavant
SoftwareSavant

Reputation: 9737

Javascript files not being found

This is the weirdest thing. When I moved what little working code I had from my development setup to some kind of test server (and believe me when I tell you that that was painfull), I realized that all of my Javascript functionality wasn't working. After doing a little investigation (fiddler2), I found that I am getting a 404 error when loading my scripts. Well when I look in the directory where the code says they are located, I am ABLE to find them. In other words, they are where they said they were. What in sam hill is going on here? Could it possible be how I have my IIS server set up? I looked in the Handler mappings for my website (one of several websites on this server under the sites\default web site node) in IIS I noticed that .js is not even found in there. Would that have anything to do with it? If that is way off base, have you ever experienced anything like this? How can I go about solving this issue?

Thanks for your help.

EDIT: Examples of how I call my scripts

    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/dataTable.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../../Content/jqUIcss/jquery-ui-1.8.14.custom.css" />      
    <script type="text/javascript" src="../../Scripts/jquery-1.5.1.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jqUI/jquery-ui-1.8.14.custom.min.js"></script>
<asp:ContentPlaceHolder ID="HeadContent" runat="server" />

EDIT 2 Just checked and my application pool inside of IIS 7 is set to integrated. So that probably isn't it.

Upvotes: 0

Views: 3314

Answers (4)

TheWizardOfTN
TheWizardOfTN

Reputation: 187

This happened to me with I was using MS Edge.

I went to the upper right hand corner, clicked the three dots, clicked 'More Tools', 'Developers Tools' to get the developers window

Then I right-clicked on the browser's 'Refresh' icon (the circle arrow), and selected 'Empty Cache and Hard Refresh'.

Everything was then fine. It's one of those answers that's sometimes too easy to get

Upvotes: 0

jboo
jboo

Reputation: 374

I had a similar problem with asp.net mvc and css and javascript url.

Sometimes I need to use the function Page.ResolveClientUrl

and other time Page.ResolveUrl does the tricks

Upvotes: 0

SoftwareSavant
SoftwareSavant

Reputation: 9737

Figured it out...

Talking to a co-worker of mine I discovered what he does in situations like this...

    <script src="<%=ResolveClientUrl("~/Scripts/lib/jquery.js")%>" type="text/javascript"></script>

ResolveClientUrl plus the "~" infront of the Folder where I expect the jquery library to be seems to work.

Upvotes: 0

cpoDesign
cpoDesign

Reputation: 9153

My thought about your problem.

Did you drag and drop the file name into view? (this will fill path relative to file to your js file) this is happening often if you have areas.

step 1 check that file name is in correct location and you have the correct name.

step 2 check whether you can access file from url link on the location you know to be sitting in

step 3 validate your request via firebug or something else that will show you request for the file.

step 4 is the file / folder accessible via your application / do you have access rights to the location

if this fails i would presume there is something wrong with IIS or settings of your application/ website

this is just quick thought for you...

Upvotes: 1

Related Questions