代码之家  ›  专栏  ›  技术社区  ›  Andre.Santarosa

Angular 7应用程序刷新不适用于IIS,即使web.config文件配置

  •  0
  • Andre.Santarosa  · 技术社区  · 6 年前

    我对Angular7应用程序有一个奇怪的行为。每次我点击刷新,它就会失去路线的轨迹,给我一个404。我在很多地方都读过关于配置web.config文件为了解决这个问题,但是即使配置了它,我也无法摆脱这种行为。

    <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="/" />
    
      </rule>
    
    </rules>
    

    模块配置

    @NgModule({
      imports: [
        AppRoutingModule,
        SharedModule,
        HttpClientModule,
        AuthModule,
        StoreModule.forRoot(reducers, { metaReducers }),
        EffectsModule.forRoot(effects),
        StoreRouterConnectingModule,
        environment.development ? StoreDevtoolsModule.instrument() : []
      ],
      declarations: [AppComponent],
      providers: [
        { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
        { provide: RouterStateSerializer, useClass: CustomSerializer }],
      bootstrap: [AppComponent]
    })
    export class AppModule {}
    

    <base href="/" /> 在我的头上索引.html文件

    1 回复  |  直到 6 年前
        1
  •  0
  •   PuntanetDeveloper    6 年前

    在这个文件夹中,你应该有一个项目名称的文件夹,试着把这个文件夹的内容直接移到这个目录下