Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 4应用程序部署到IIS 8.5后无法工作_Angular_Iis - Fatal编程技术网

Angular 4应用程序部署到IIS 8.5后无法工作

Angular 4应用程序部署到IIS 8.5后无法工作,angular,iis,Angular,Iis,我的环境要求我使用IIS作为web服务器和Visual Studio 2015 我完全遵循了这个例子 当我点击F5,解决方案在VisualStudio中使用IIS Express时,一切都很好 当我发布到本地完整版本的IIS时,一切都会崩溃 当我转到URL时,我得到一个403禁止的错误。即使src/index.html被设置为我的起始页,它也不会路由到它 如果我在完整路径中输入:,页面将尝试加载,但随后会出现所有404错误,因为Angular不包括虚拟目录。 当我查看Angular的部署文档时

我的环境要求我使用IIS作为web服务器和Visual Studio 2015

我完全遵循了这个例子

当我点击F5,解决方案在VisualStudio中使用IIS Express时,一切都很好

当我发布到本地完整版本的IIS时,一切都会崩溃

  • 当我转到URL时,我得到一个403禁止的错误。即使src/index.html被设置为我的起始页,它也不会路由到它

  • 如果我在完整路径中输入:,页面将尝试加载,但随后会出现所有404错误,因为Angular不包括虚拟目录。

  • 当我查看Angular的部署文档时,他们对IIS所说的只是确保安装了IIS重写模块,我已经安装了该模块

    我已经搜索了几天关于如何解决这个问题,我觉得在如何将它部署到完整版本的IIS上,他们提到的唯一一件事就是让IIS重写

    是否有其他人将Angular 4应用程序部署到IIS的完整版本

    以下是我的配置文件:

    index.html

    <!DOCTYPE html>
    <html>
      <head>
        <base href="/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>
    

    尝试更改基本元素:

    你的Angular“app”文件夹在哪里。它在根上吗?
    <?xml version="1.0" encoding="utf-8"?>
    <!--
      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"/>
        <httpModules>
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
        </httpModules>
      </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=\&quot;Web\&quot; /optionInfer+"/>
        </compilers>
      </system.codedom>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
          <remove name="ApplicationInsightsWebTracking"/>
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
            preCondition="managedHandler"/>
        </modules>
        <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="/src/" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    
    /**
     * 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 look for things
        map: {
          // our app is within the app folder
          'app': 'app',
    
          // angular bundles
          '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
          '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
          '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
          '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
          '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
          '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
          '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
          '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
          '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
          '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
          '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
          '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
          '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
          '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
    
          // other libraries
          'rxjs':                      'npm:rxjs',
          'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
          app: {
            main: './main.js',
            defaultExtension: 'js',
            meta: {
              './*.js': {
                loader: 'systemjs-angular-loader.js'
              }
            }
          },
          rxjs: {
            defaultExtension: 'js'
          }
        }
      });
    })(this);