UseWebpackDevMiddleware AggregateException

时间:2018-09-06 13:47:56

标签: c# webpack asp.net-core-mvc

我尝试使用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)

该异常发生在Configure方法中的Startup.cs中:

        app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
        {
            HotModuleReplacement = true
        });

似乎某些JSON文件格式错误?但是哪一个。我是NPM和Webpack的新手。

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

1 个答案:

答案 0 :(得分:1)

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

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

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