2

I deployed my dot net core 3.1 api and angular 9 app into IIS. Api works well. When I hit the url for login it works well and took me into my Dashboard. http://192.168.15.12:8020/ePortal/home.

After that when I click on my other component say I wants to go to Color. When I click on Color the urls is http://192.168.15.12:8020/home/color-details instead of http://192.168.15.12:8020/ePortal/home/color-details that's why it shows 404(not found) error.

I've build the production using ng build --prod --base-href /ePortal/ and also add an web.config to rewrite the url

<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="/ePortal/" />
        <!--<action type="Rewrite" url="/" /> /ePortal/-->
      </rule>
    </rules>
  </rewrite>
</system.webServer>
</configuration>

I can't identify the problem. Help please

2 Answers 2

2

It is an angular routing issue. You are using relative path but you need to use absolute pathing for this. try add "/" before your routerlink.

Example: instead of routerLink = "color" use routerLink = "/color"

Update

use this

<a mat-list-item href="color-details">Color</a>
Sign up to request clarification or add additional context in comments.

3 Comments

<a mat-list-item href="/home/color-details">Color</a> I used this.
When I click on Color the url should be http://192.168.15.12:8020/ePortal/home/color-details but it's not rewritting. it goes on http://192.168.15.12:8020/home/color-details
Thans a lot. It'll be <a mat-list-item href="home/color-details">Color</a> the error occurs due to / before home
0

Solutation

you can not redirect different path dir into angular,so you need to add custom for it

Example :

<a href="home/color-details">Color</a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.