我的ASP.NET Core Angular 2网络应用程序出现间歇性异常:
Exception: Call to Node module Failed with error: Error: This method is not implemented in Parse5DomAdapter: Parse5DomAdapter#getCookie at _notImplemented (D:\Projects\MyProject\MyProject\node_modules\angular2-platform-node\parse5-adapter.js:22:12) at Parse5DomAdapter.getCookie (D:\Projects\MyProject\MyProject\node_modules\angular2-platform-node\parse5-adapter.js:641:15) at CookieXSRFStrategy.configureRequest (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:1597:92) at XHRBackend.createConnection (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:1637:32) at httpRequest (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:1975:24) at Http.get (D:\Projects\MyProject\MyProject\node_modules\@angular\http\bundles\http.umd.js:2086:20) at ApiService.getChatMessages (D:\Projects\MyProject\MyProject\ClientApp\dist\main-server.js:557:20) at ChatPageComponent.ngOnInit (D:\Projects\MyProject\MyProject\ClientApp\dist\main-server.js:513:23) at AppView._View_ChatPageComponent_Host0.detectChangesInternal (ChatPageComponent_Host.ngfactory.js:30:86) at AppView.detectChanges (D:\Projects\MyProject\MyProject\node_modules\@angular\core\bundles\core.umd.js:9566:18) MoveNext
MoveNext in Index.cshtml 1.@{ 2. ViewData["Title"] = "Home Page"; 3.} 4. 5.<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app> 6. 7.<script src="~/dist/vendor.js" asp-append-version="true"></script> 8.@section scripts {
这是我的index.cshtml中的代码.
这似乎发生在项目启动后的早期.这一切都可以正常工作,或者在执行任何导航时加载主页后会抛出错误.
我可以强迫它产生错误.我有4个导航目的地:
http://localhost:49954/home http://localhost:49954/counter http://localhost:49954/fetch-data http://localhost:49954/chat-page
这些都是从Visual Studio Angular 2模板设置的.如果我刷新回家,一切都很好,如果它有机会加载一段时间我可以导航到其他页面.但是,如果我输入任何其他页面的URL,则每次都会产生此错误.
编辑:另外,有趣的是,它与http:// localhost:49954 / counter产生了略微不同的错误.在我的计数器页面中,我使用了Angular Material Design组件:
<div class="mine"> <h2> Counter Test </h2> <p>This is a simple example of an Angular 2 component.</p> <p>Current count:<strong>{{ currentCount }}</strong></p> <button md-raised-button (click)="incrementCounter()">Increment</button> </div>
而不是上面的错误,它是一个类似的调用节点模块失败错误,但在材料设计中:
Exception: Call to Node module Failed with error: Error: Uncaught (in promise): ReferenceError: document is not defined ReferenceError: document is not defined at new RippleRenderer (D:\Projects\MyProject\MyProject\node_modules\@angular\material\material.umd.js:193:31)
这对我有用.更改:
原文链接:https://www.f2er.com/angularjs/143211.html<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
至
<app asp-ng2-prerender-module="ClientApp/dist/main-server">Loading...</app>
在index.html中