0
我正在尝试配置Angular 4应用程序在本地IIS上运行。为Angular 4应用程序配置IIS的错误
关于如何配置Visual Studio环境,我有followed the instructions from Angular。该应用程序在IIS Express中运行良好。
我已经安装了IIS Rewrite Module成功地进入我的本地IIS
我创建了一个虚拟目录我的角度应用程序来执行的,它的英雄应用的功能齐全的旅游。
当我部署应用程序,我得到404错误,因为服务器没有找到文件,它,因为它不包括虚拟目录路径:
这是我的index.html
文件:
<!DOCTYPE html>
<html>
<head>
<base href="/TOHWeb/src/">
<title>Angular Tour of Heroes</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- Polyfills -->
<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="systemjs.config.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
这里是我web.config
:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/TOHWeb/src/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
这里是我的systemjs.config.js
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': '/node_modules/'
},
// map tells the System loader where to l
片断我觉得我失去了一些东西很小,被摆脱的路径,但刚好可以似乎找不到它。感谢您的任何建议!
你如何部署你的应用程序?通常有一个“npm install”的构建步骤,它将为您获取所有这些node_modules。没关系,因为你不希望那些在源代码控制中。 – vidalsasoon
现在,我受限于直接在本地IIS中使用Visual Studio中的“发布”。所以我必须手动将'node_modules'复制到目录。 – Flea
确实“http://localhost/TOHWeb/node_modules/core-js/client/shim.min.js”给出了一个http代码200? – vidalsasoon