ASP.NET Core 2.0 Angular 4 universal app in production

I published my pre-rendered Angular 4 web app (ASP.Net Core 2.0, aspnet-prerendering, aspnet-webpack, VS2017), deployed it to an IIS 8 web server. The deployed bundle is pre-compiled, pre-rendered, pure javascript, no typescript in it.

It's working as expected: loads fast from the IIS server on localhost. But if I try to access it via the domain name (eg mysite.com), remotely or from another computer in the same LAN with the web server, then it takes 20+ seconds to receive the very first response from the server. In the browser, after "connecting" to the server, the app loads as fast as it does on localhost. Only the remote access is problematic.

Note 1: As a test, I have added an empty page to the site which loads instantly via the domain name, but when I navigate to the app page, it slows down. This latter test proves me that the DNS is OK and that it is not a network problem.

Note 2: Another strange thing is that it requires the node.exe to be copied into the app folder. Otherwise it complains for it, and won't start.

Note 3: I turned on stdout logging too in the web.config and the log file contains a series of errors like this:

fail: Microsoft.AspNetCore.NodeServices[0]
      Response {
        _body: 
         ProgressEvent {
           type: 'error',
           target: 
            XMLHttpRequest {
              onloadstart: null,
              onprogress: null,
              onabort: null,
              onerror: null,
              onload: null,
              ontimeout: null,
              onloadend: null,
              _listeners: [Object],
              onreadystatechange: null,
              _anonymous: undefined,
              readyState: 4,
              response: null,
              responseText: '',
              responseType: '',
              responseURL: '',
              status: 0,
              statusText: '',
              timeout: 0,
              upload: [XMLHttpRequestUpload],
              _method: 'GET',
              _url: [Url],
              _sync: false,
              _headers: [Object],
              _loweredHeaders: [Object],
              _mimeOverride: null,
              _request: null,
              _response: null,
              _responseParts: null,
              _responseHeaders: null,
              _aborting: null,
              _error: null,
              _loadedBytes: 0,
              _totalBytes: 0,
              _lengthComputable: false },
           currentTarget: 
            XMLHttpRequest {
              onloadstart: null,
              onprogress: null,
              onabort: null,
              onerror: null,
              onload: null,
              ontimeout: null,
              onloadend: null,
              _listeners: [Object],
              onreadystatechange: null,
              _anonymous: undefined,
              readyState: 4,
              response: null,
              responseText: '',
              responseType: '',
              responseURL: '',
              status: 0,
              statusText: '',
              timeout: 0,
              upload: [XMLHttpRequestUpload],
              _method: 'GET',
              _url: [Url],
              _sync: false,
              _headers: [Object],
              _loweredHeaders: [Object],
              _mimeOverride: null,
              _request: null,
              _response: null,
              _responseParts: null,
              _responseHeaders: null,
              _aborting: null,
              _error: null,
              _loadedBytes: 0,
              _totalBytes: 0,
              _lengthComputable: false },
           lengthComputable: false,
           loaded: 0,
           total: 0 },
        status: 0,
        ok: false,
        statusText: '',
        headers: Headers { _headers: Map {}, _normalizedNames: Map {} },
        type: 3,
        url: null }

Does anybody have any idea what can cause the 20+ second delay? And why I need to deploy the node executable with the app?

Thank you

链接地址: http://www.djcxy.com/p/52542.html

上一篇: Angular 5 + AspNetCore + SpaServices + cshtml可以这样做吗?

下一篇: 生产中的ASP.NET Core 2.0 Angular 4通用应用程序