0

Does anyone has any experience of hosting Angular 2 website in an IIS application (not Site)? I created an Angular 2 app with base href of "/" in my index.html and all my routing is on base level. As shown in the picture below, my app is now hosted in the BuildingProjects site (the one that is stopped). However I'm trying to host it under the Default Web Site in de BuildingProjects application. I tried to change the base href as shown below, but then all my routing to next components fails. The extra pitfall is that the app is authentication over AzureAD. The reply URL is set to .../Test/BuildingProjects/id_token, but this gives me the message that there is a wrong reply URL.

<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

I tried everything to put the custom base path in the routes in every kind of combination, but without any succes.

EDIT

Also tried

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>

NiAu
  • 535
  • 1
  • 12
  • 32
  • check this https://stackoverflow.com/questions/35459459/how-and-what-to-deploy-angular2-to-iis – Fateh Mohamed Oct 27 '17 at 10:27
  • or If you have ASP.NET Core 2.0 this https://dustinewers.com/angular-cli-with-net-core/ – Eliseo Oct 27 '17 at 10:34
  • @Eliseo This link is not about hosting Angular 2 to IIS. My project is also a .NET Core with Angular in. – NiAu Oct 27 '17 at 12:59
  • @FatehMohamed See Edit. I already tried this link, but without any success. – NiAu Oct 27 '17 at 13:04
  • https://stackoverflow.com/questions/46532182/angular-4-documentation-offline-computer/46532743?noredirect=1#comment80318868_46532743 ? – Eliseo Oct 28 '17 at 12:15

0 Answers0