问题
I am running a Windows 7 Professional PC, using Visual Studio 2017 version 15.4.5. When I created a .Net Core 2.0 project and selected the type of Angular, it ran fine out of the box.
Then I added font awesome and primeng (https://www.primefaces.org/primeng/#/) in what I think is the standard way, i.e., adding references to the package.json file, then to the nonTreeShakableModules section of the webpack.config.vendor.js file, then adding modules to app.module.shared.ts. This was primeng version 5.0.2 and font-awesome version 4.7.0.
At first, it worked fine - font awesome classes worked, and a button showed all the expected features of a primeng button when I added test html to the home page.
Then I stopped debugging and hit F5 to build again, and I got the error described below - this is what shows up in my web browser (Chrome, IE or Firefox). After rebooting my PC, it worked fine again the first time, but again, as soon as I stopped debugging and hit F5 again, I got the same error. Last time I rebooted, even that did not help. I have Googled all afternoon, but no answer on what might cause this.
Can anyone help?
Here is what I see in my browser, at the top:
An unhandled exception occurred while processing the request.
WinHttpException: The connection with the server was terminated abnormally
Unknown location
IOException: The read operation failed, see inner exception.
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
HttpRequestException: Error while copying content to a stream.
System.Net.Http.HttpContent+d__48.MoveNext()
回答1:
This is what fixed the problem for me. In the Index.cshtml page, instead of this tag, which Microsoft conveniently provides out of the box:
<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
Change it to to this:
<app asp-ng2-prerender-module="ClientApp/dist/main-server" asp-prerender-timeout="100000">Loading...</app>
Now why in the world we would not get an ng2 prerender module as the default when you choose an Angular project type is beyond me - I'm sure Microsoft has some good reason, right?
来源:https://stackoverflow.com/questions/47562531/vs-2017-net-core-2-0-angular-4-error-system-net-http-winhttpexception-the-c