This is my project structure. I have index.html outside app folder. When I run my application in local it works proper. Angular2 routing and page rendering is working proper in local machine.
But when I host this application on server. Page routing is not working.
I hav include following code in my web .config to re write URL and then I am able to called index.html page as default page.
`
<system.webServer>
<rewrite>
<rules>
<rule name="Angular2" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="/index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
`
But yet angular2 page is not rendered.
Also I have released my application in root domain. and included
<base href="/"> in index.html page too.
Please suggest me what should I do?
Finally I found my solution. My internal network(firewall) was blocking my angular 2 app from loading dynamic pages. With the help of network guys I solved that issue.
Apart from it URL rewriting and base path is still needed to load angular app on server.
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With