The solution to my problem (getting the tutorial working in a local IIS
8.5, as application running under the default website, hence with the URL
like http://localhost/QuickStart/) includes the following steps:
1 - web.config:
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
</files>
</defaultDocument>
<rewrite>
<rules>
*<rule name="Angular2" stopProcessing="true">*
* <match url=".*" />*
* <conditions logicalGrouping="MatchAll">*
* <add input="{REQUEST_FILENAME}" matchType="IsFile"
negate="true" />*
* <add input="{REQUEST_FILENAME}"
matchType="IsDirectory" negate="true" />*
* <add input="{REQUEST_URI}" pattern="^/$"
negate="true"/>*
* </conditions>*
* <action type="Rewrite" url="/QuickStart/" />*
* </rule>*
</rules>
</rewrite>
</system.webServer>
2 - index.html:
<head>
*<base href="/QuickStart/">*
<title>Angular QuickStart</title>
3 - app-routing.module.ts:
const routes: Routes = [
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: DashboardComponent },
{ path: 'detail/:id', component: HeroDetailComponent },
{ path: 'heroes', component: HeroesComponent }
];
The solution should be applicable to any Angular 2 app that needs to be
deployed in IIS, so I hope this helps other people as well!
Have a nice day,
M
Op maandag 16 januari 2017 19:31:33 UTC+1 schreef Mauro Ebert:
>
> Hello everybody,
>
> I'm new to Angular 2 and interested in eventually consider adopting it for
> my company's web development projects, so I decided to have a look at its
> capabilities by following the Tour of Heroes tutorial.
> I have used the instructions provided in Cookbook > VS 2015 QuickStart to
> set up the project and add the quickstart-master files.
>
> Everything worked fine until I had to perform the steps in 6. Routing (as
> warned in the instructions at the end of the project setup).
> After following the steps to add the router outlet and link in the code,
> the tutorial app shows the message hard-coded in index.html ("Loading
> AppComponent content here ..."), instead of the app component html.
>
> In order to solve the issue, I then added a rewrite rule into my
> web.config, which contains the following:
>
> <system.webServer>
> <rewrite>
> <rules>
> <rule name="Angular2" stopProcessing="true">
> <match url=".*" />
> <action type="Rewrite" url="/" />
> </rule>
> </rules>
> </rewrite>
> </system.webServer>
>
> Unfortunately, this apparently doesn't help (has no effect) in getting the
> expected behavior back.
> I'd truly appreciate if someone with (some) more knowledge could shed some
> light on the problem, what I am possibly doing wrong and its actual
> solution.
>
> Thank you in advance!
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.