2 years ago
#74864
Frimlik
Angular 10 on IIS - cannot open link (component) in new tab, always redirected to index/404.0 error displayed
In my Angular application deployed on IIS I want to open link 'Contact' in new tab via the following link:
<a [routerLink]="['/contact']">Contact</a>
The problem is that in the new tab I find index page. Previously I had a problem with refreshing page which I solved by this given to web.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" 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="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
After reading many inputs on stackoverflow and elsewhere I suspect this setting to be responsible for this behavior, but am not sure.
Is there a way to combine correct behavior of refresh and ability to open link in new tab in Angular app deployed to IIS?
EDIT
Now I understand the construction. It means if I try to access anything except file or directory, my request is redirected to index.html.
I added (prepended) another rule to avoid redirecting:
<rule name="Contact link" stopProcessing="true">
<match url="contact" />
<action type="None" />
</rule>
This ensures that any request to contact page is not redirected. But at the same time, for obvious reason, I get a 404.0 error, because no index file is found at that location.
So new question is: Is there any way how to open angular component in new tab?
angular
iis
angular-ui-router
0 Answers
Your Answer