I have an Angular 2 rc-2 app with basic routing implemented.The paths are /path1
which is the default path and /path2
.The home path /
redirects to /path1
. When I run it locally (lite-server) everything works fine. I managed to deploy this app to an Azure web app. The app works OK BUT if I refresh the page when I m in /path1
or /path2
I get this error : The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
A possible approach is to implement url rewrite. I added a web.config file in my project
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<!-- check if its path1 url and navigate to default page -->
<rule name="Path1 Request" enabled="true" stopProcessing="true">
<match url="^path1" />
<action type="Redirect" url="/index.html" logRewrittenUrl="true" />
</rule>
<!-- check if its path2 url and navigate to default page -->
<rule name="Path2 Request" enabled="true" stopProcessing="true">
<match url="^path2" />
<action type="Redirect" url="/index.html" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
In this case I can make a refresh without getting this error message.But any refresh redirects me to the default url. I refresh from /path2
and it redirects me to /path1
(default url).
Any thoughts to improve refresh ? :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…