c# - UseWebpackDevMiddleware AggregateException
问题描述
我尝试使用 NPM/Webpack/Vue.js 创建一个 ASP.NET Core MVC 应用程序。我正在关注本教程: https ://marczak.io/posts/netcore-vuejs/
启动项目时,出现此异常:
An exception of type 'System.AggregateException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'One or more errors occurred.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception Newtonsoft.Json.JsonReaderException : Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
异常发生在 Startup.cs 的 Configure 方法中:
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true
});
似乎某些 JSON 文件格式错误?!但是哪一个。我是 NPM 和 Webpack 的新手。
如果您需要更多信息,请告诉我。
解决方案
发现这个 dotnet 问题:https ://github.com/dotnet/core/issues/1726
我在代理后面,需要停用它(我不能)或在 Program.cs 的 Main() 方法中添加此行,然后再添加:
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
推荐阅读
- python - 使用 Ansible jinja 过滤器 to_yaml 生成多行 YAML
- javascript - React 中的多个 If 语句
- c# - 仅当控件可见时运行 WPF 验证(如果控件折叠则禁用验证)
- reactjs - React 动态导入图片
- bash - 使用另一个对象列表过滤列表
- c# - 通过单击关联文件打开 C# Winforms 应用程序
- python - AuthFailed 在 /social-auth/complete/linkedin-oauth2/
- r - 是否有一个函数可以找到用于在 R 中构建 h2o 模型的许多观察值?
- javascript - 如何在动态对象的字段中添加数字并使用 lodash 删除空字段?
- php - 使用 jQuery 单击时从作为数组的按钮 ID 获取键