Solved

Local IIS in windows 8.1 do not load scripts

Posted on 2014-12-29
4
184 Views
Last Modified: 2015-01-14
Hi.
I have a web application using jquery. is the example of Brady Gaster at TechEd 2014.

well. When I run it from IISExpress it runs ok.
When I run it from IIS site, I got to 404 for all scripts. The scripts are referred to as:
     <script src = "Scripts / jquery-2.1.1.js"> </ script>
     <script src = "scripts / jquery.signalR-2.1.2.js"> </ script>
When I run the application, in F12, I got this:

  Resource interpreted the script but Transferred with MIME type text / plain: "http: //localhost/HitCounter/Scripts/jquery-2.1.1.js".
Default.aspx: 10 Resource interpreted the script but Transferred with MIME type text / plain: "http: //localhost/HitCounter/Scripts/jquery.signalR-2.1.2.js".
Because of this, I got an "$  is not defined"

the default.aspx is :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="HitCounter.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-2.1.1.js"></script>
    <script src="Scripts/jquery.signalR-2.1.2.js"></script>
    <script type="text/javascript">

            $(function () {
                var con = $.hubConnection();
                var hub = con.createHubProxy('hitCounter');
                hub.on('onHitRecorded', function (i) {
                    $('#hitCount').text(i);
                });
                con.start(function () {
                    hub.invoke('recordHit');
                });

            })

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <div id="hitCount" style="font-size: 200px;"></div>
        </div>
    </form>

</body>
</html>

Open in new window

0
Comment
Question by:Deraldo Silva
  • 2
  • 2
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40522752
1/ do you really have spaces in your paths ? be sure to remove them.

If you don't have spaces :
2/ Add a mime for << js >> extension
http://technet.microsoft.com/en-us/library/cc725608%28v=ws.10%29.aspx

Or another way :
you can use CDN too so speed up page loading if its' published :
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src = "//ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.1.0.min.js"> </ script>

Open in new window

0
 

Author Comment

by:Deraldo Silva
ID: 40523365
Hi leakim971.
thx for your attention.
there should be no spaces because I simply drag from solution explorer and dropped in <head>

the mime types is .js to application/javascript ( is this correct?)
and the scripts were all brought by nuget.

I just add the CDN and the problem of the undefined is gone. But I got this:

/signalr/negotiate?clientProtocol=1.4&connectionData=%5B%7B%22name%22%3A%22hitcounter%22%7D%5D&_=1419935615870      HTTP      GET      404      text/html      5,18 KB      < 1 ms      XMLHttpRequest      485      0      0      0      0      70

Can you help me? or I need to open another question?
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40523460
yes, would be better to open another question
your mime type for js extension look fine, maybe you've a file (htaccess) or setting overwritting the mime somewhere
0
 

Author Comment

by:Deraldo Silva
ID: 40523645
ok. but about the CDN solution, is not the good solution. it simply moves the responsability from local to CDN. If I dont have internet access (and sometimes I dont) it not works.
I will reinstall the visual studio because I feel that there is the problem.
I report it here
anyway, you have found what is the problem.

thx for your attention
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 List with Ratings 6 91
Javascript_Set_dropdown_value 7 40
Jquery keyup 4 25
Question about traversing a tree using jQuery 7 33
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question