Deploy .NET Core ServiceStack App as a virtual application in IIS

We deployed the .NET Core ServiceStack App as a virtual application in IIS.
The address is “https://mysite/api”.
The base app was developed using angular.
The problem is that the ‘/hello’ call result, which is a sample of the ServiceStack, is not what I want.

To run the .Net Core Virtual Application below the Angular site,
I added the web.config file to the angular site and applied the following URL Rewrite rules.

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Web API rule" stopProcessing="true">
                    <match url="/api/.*" />
                    <action type="None" />
                </rule>
                <rule name="Angular rule">
                    <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>

If I call https://mysite/api/hello with [Route("/hello")], browser redirect to angular web site(root).
If I call https://mysite/api/api2/hello with [Route("/api2/hello")], browser redirect to angular web site(root).
If I call https://mysite/api/api/hello with [Route("/api/hello")], it’s working.

But in any case, there was no way to call /metadata.

Do I have to enter the Route attribute with ‘/api’, which is the path to the Virtual Application?
Can I set the path of the Virtual Application to Base url and let it run automatically?

I need a guide to add an Angular site to IIS and upload a ServiceStack to a Virtual Application.
Help!

The only supported option is to use the <location path="..."> element as demonstrated in Run side-by-side with another Framework docs:

<configuration>
  <!-- ... --> 
  <location path="api">
    <system.web>
      <httpHandlers>
        <add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*"/>
      </httpHandlers>
    </system.web>

    <!-- Required for IIS 7.0 -->
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true"/>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers>
        <add path="*" name="ServiceStack.Factory" 
             type="ServiceStack.HttpHandlerFactory, ServiceStack" 
             verb="*" preCondition="integratedMode" 
             resourceType="Unspecified" allowPathInfo="true" />
      </handlers>
    </system.webServer>
  </location>
  <!-- ... --> 
</configuration>

Whatever path you put in the location should also be specified in Config.HandlerFactoryPath, e.g:

public override void Configure(Container container)
{
    SetConfig(new HostConfig { HandlerFactoryPath = "api" });
}

Sorry that’s only for ASP.NET, for .NET Core you should just be able to set the HandlerFactoryPath:

SetConfig(new HostConfig {
    HandlerFactoryPath = "api",
});

i.e. without any of the rewrite rules, then you should be able to access your APIs like: