首页 > 解决方案 > 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 的新手。

如果您需要更多信息,请告诉我。

标签: c#webpackasp.net-core-mvc

解决方案


发现这个 dotnet 问题:https ://github.com/dotnet/core/issues/1726

我在代理后面,需要停用它(我不能)或在 Program.cs 的 Main() 方法中添加此行,然后再添加:

AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);

推荐阅读