angular - Angular2 - page refresh 404ing when hosted in Azure -


i working on angular2 app. uses "@angular/common": "2.0.0-rc.4" , "@angular/router": "3.0.0-beta.2".

my problem when use browser refresh on of pages see error saying...

"the resource looking has been removed, had name changed, or temporarily unavailable."

this happens if hit url directly.

an example url is... https://tilecasev2.azurewebsites.net/profile/therichmond

however if view pages via homepage work ok until refreshed (https://tilecasev2.azurewebsites.net).

i have below in index.html head...

<base href="/">  

why happen , how can fix it?

hashlocationstrategy avoids issue including # in of angular routes doesn't fix it.

to make angular routes without hashes work in azure same way in local development environment, need configure iis rewrite requests root. lets angular handle routing.

to this, add web.config file site's root folder following contents:

<configuration> <system.webserver>     <rewrite>       <rules>         <rule name="main rule" stopprocessing="true">                 <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> </configuration> 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -