IIS 10 is throwing the error

404 File or directory not found

Only when I try to access the url with subfolder path like this:

http://myserveraddress.com/object/181

So it works without the subfolder. The subfolder path is used by Angular to query a rest interface so there is no physical folder path behind it, just used for querying behind the schene.

This actually works when running on localhost but not on the server.

Is it possible to configure IIS such that it allows any url path even though the physical folder path does not exist?

2 Answers

0
doorman On Best Solutions

The solution was to add this to the Angular client web.config file

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="AngularJS 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="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

More detail can be found here Get Angular2 routing working on IIS 7.5

1
Chiranth Ramaswamy On

This loos more like a handler configuration issue, and also if your server is a brand new server may be you haven't installed the handlers which is supposed to process your request, if i have to take a request if you haven't configured the rest handlers required it is goind to the static file handler which tries to look for a folder in the request url path and throw an error, if you already have a setup running, check all the handlers and pre-requisites installed there and mimic the setting over in the new server as well