在IIS应用程序中托管Angular 2应用程序

时间:2017-10-27 10:06:39

标签: angular iis angular-ui-router azure-active-directory

有没有人有任何在IIS应用程序(而非网站)中托管Angular 2网站的经验?我创建了一个Angular 2应用程序,基本href为" /"在我的index.html中,我的所有路由都在基础级别上。如下图所示,我的应用程序现在托管在BuildingProjects站点(已停止的站点)中。但是,我试图在de BuildingProjects应用程序的默认网站下托管它。我尝试更改基本href,如下所示,但然后我的所有路由到下一个组件失败。额外的缺陷是应用程序是AzureAD上的身份验证。回复网址设置为... / Test / BuildingProjects / id_token,但这会给我一条错误回复网址的消息。

<base href="/">       -->         <base href="/Test/BuildingProjects/">

RouterModule.forRoot([
      { path: 'id_token', component: OAuthCallbackComponent, canActivate: [OAuthCallbackHandler] },                   // reply URL AAD
      { path: 'projects', component: ProjectsComponent, canActivate: [AuthenticationGuard] },
      { path: 'login', component: LoginComponent },
      { path: '', redirectTo: 'login', pathMatch: 'full' },
      { path: 'loading', component: OAuthCallbackComponent }
  ]),

enter image description here

我尝试了所有方法将自定义基本路径放在各种组合的路径中,但没有任何成功。

修改

也试过

base href="//"

的Web.config

<configuration>
<system.webServer>
    <rewrite>
    <rules>
        <rule name="Main Rule" >
                <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>
    </rewrite>
</system.webServer>

0 个答案:

没有答案