VS 2017 .Net Core 2.0,Angular 4,错误:System.Net.Http.WinHttpException:与服务器的连接异常终止 [英] VS 2017 .Net Core 2.0, Angular 4, Error: System.Net.Http.WinHttpException: The connection with the server was terminated abnormally

查看:86
本文介绍了VS 2017 .Net Core 2.0,Angular 4,错误:System.Net.Http.WinHttpException:与服务器的连接异常终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Windows 7 Professional PC,使用 Visual Studio 2017 版本 15.4.5.当我创建一个 .Net Core 2.0 项目并选择 Angular 类型时,它开箱即用.

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.

然后我添加了字体 awesome 和 primeng (https://www.primefaces.org/primeng/#/) 以我认为的标准方式,即添加对 package.json 文件的引用,然后添加到 webpack.config.vendor.js 文件的 nonTreeShakableModules 部分,然后将模块添加到 app.module.shared.ts.这是 Primeng 5.0.2 版和 font-awesome 4.7.0 版.

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.

起初,它工作得很好 - 字体很棒的类工作,当我将测试 html 添加到主页时,一个按钮显示了一个 Primeng 按钮的所有预期功能.

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.

然后我停止调试并按 F5 再次构建,我得到了下面描述的错误 - 这就是我的网络浏览器(Chrome、IE 或 Firefox)中显示的内容.重新启动我的电脑后,它第一次再次正常工作,但是再次,一旦我停止调试并再次按下 F5,我得到了同样的错误.上次我重新启动时,即使那样也无济于事.我整个下午都在谷歌上搜索,但没有回答可能导致这种情况的原因.

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.

有人可以帮忙吗?

这是我在浏览器中看到的顶部:

Here is what I see in my browser, at the top:

处理请求时发生未处理的异常.

An unhandled exception occurred while processing the request.

WinHttpException: 与服务器的连接已终止异常

WinHttpException: The connection with the server was terminated abnormally

未知位置

IOException:读取操作失败,查看内部异常.

IOException: The read operation failed, see inner exception.

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

HttpRequestException:将内容复制到流时出错.

HttpRequestException: Error while copying content to a stream.

System.Net.Http.HttpContent+d__48.MoveNext()

System.Net.Http.HttpContent+d__48.MoveNext()

推荐答案

这就是为我解决问题的方法.在 Index.cshtml 页面中,而不是 Microsoft 方便地提供开箱即用的此标记:

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>

改成这样:

<app asp-ng2-prerender-module="ClientApp/dist/main-server" asp-prerender-timeout="100000">Loading...</app>

现在为什么当您选择 Angular 项目类型时我们不会将 ng2 预渲染模块作为默认设置超出我的范围 - 我相信微软有充分的理由,对吧?

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?

这篇关于VS 2017 .Net Core 2.0,Angular 4,错误:System.Net.Http.WinHttpException:与服务器的连接异常终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆