Solved

Local IIS in windows 8.1 do not load scripts

Posted on 2014-12-29
4
174 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now