0

I include moment in my ASPNET BundleConfig

                    "~/Scripts/bootstrap.min.js",

                    "~/Scripts/moment-with-locales.min.js",

I have two web servers:

  • A: Windows Server 2008, IIS 7.5, .NET 4.6.2
  • B: Windows Server 2012, IIS 8.0, .NET 4.6.2

When using B, in Firebug, I see the GET for both come back as 200 OK, but in the Console I see "moment is not defined".

enter image description here

I've also tried plain old moment.js in place of -with-locales but I get the same error.

Furthermore, the failure does not happen on A.

How could the webserver matter such that the file loads in the browser but the object isn't there?

Brian Ogden
  • 18,439
  • 10
  • 97
  • 176
John Mc
  • 212
  • 2
  • 16

1 Answers1

0

If the server is responding with the moment.js file when a request is made for moment.js than your server is not where the issue lies.

The issue lies with your Javascript, you are using moment in your Javascript before moment.js has been loaded in the browser. The error says "moment is not defined", it is not a 404 error as your server might return if it could not find the moment.js file.

The order the Javascript files could be different in Server B's response(s) compared to Server A's response(s)

Brian Ogden
  • 18,439
  • 10
  • 97
  • 176
  • One thing I neglected to add is the Server A is minifying and bundling the scripts where was Server B isn't. Could that have something to do with moment not being loaded before it is used? – John Mc Feb 08 '17 at 23:44
  • @JohnMc Yes, with ASP.NET bundling and minification, you set the order the of the Javascript files response in a C# file, if there is no bundling and minification, the order is different and it is defined in your index.html or a .cshtml – Brian Ogden Feb 08 '17 at 23:51
  • @JohnMc No minification itself makes no difference, the order of the Javascript files could be different on Server A compared to Server B – Brian Ogden Feb 08 '17 at 23:58
  • Alright that makes sense in theory. But I can't see how my non-minimized response from Server B could be any different to prevent the error. Firebug's Script tab shows – John Mc Feb 09 '17 at 00:08