Base solution for your next web application
Open Closed

Page reload issue(404 error) only when project is live. #7787


User avatar
0
xitix created

After publishing the project. We can only reload HOME screen else on all links when we reload page. it shows page not found error. refers screen shots. My Project Type : AspNet and Angualr [Lates v. 7.0 ]

Without Error :

Reload/Refresh Page :

After Refresh with error 404 :

See in GIF:


4 Answer(s)
  • User Avatar
    0
    xitix created

    Any update, regarding above issue. Kindly reply its urgent.

  • User Avatar
    2
    Samzzy16 created

    ASP.NET Zero Angular UI contains a web.config file. You can copy it to the web site's root folder to overcome the problem described above. Web.config contents is

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <staticContent>
          <remove fileExtension=".json" />
          <mimeMap fileExtension=".json" mimeType="application/json" />
    	  <mimeMap fileExtension="woff" mimeType="application/font-woff" />
          <mimeMap fileExtension="woff2" mimeType="application/font-woff" /> 
        </staticContent>
        <!-- IIS URL Rewrite for Angular routes -->
        <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" />
                <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks @Samzzy16 :)

  • User Avatar
    1
    jkeyser created

    These are the values that worked for me.

    <?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>