Asp.net核心与Angular 2 main.js路径错误
问题描述:
我在Angular Quickstart的帮助下用Angular 2构建了asp.net核心应用程序。Asp.net核心与Angular 2 main.js路径错误
由于Asp.Net核心应用程序允许将wwwroot作为文件夹,因此我将所有依赖关系移动到包括节点模块的文件夹中。
Layout.cshtml:
<script src="/node_modules/core-js/client/shim.min.js"></script>
<script src="/node_modules/zone.js/dist/zone.js"></script>
<script src="/node_modules/systemjs/dist/system.src.js"></script>
<script src="~/src/systemjs.config.js"></script>
<script>
System.import('main.js').catch(function (err) { console.error(err); });
</script>
ts.Config.json:
{
"compileOnSave": true,
"compilerOptions": {
"importHelpers": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"removeComments": true,
"outDir": "wwwroot/src"
}
}
现在我面临着以下错误:
http://localhost:18929/main.js 404 (Not Found)
(index):45 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:18929/main.js
答
请尝试添加在标题之后html
<base href="/" />
此链接可以帮助您解决错误。 http://asp.net-hacker.rocks/2016/04/04/aspnetcore-and-angular2-part1.html –