I created an app with ASP.NET Boilerplate (ABP) using the Module Zero Core template (Angular and ASP.NET Core, except I'm using .NET Full Framework 4.x). It works fine when I do a standard deployment to IIS (Angular running on port 80, ASP.NET Web API running on port 21021). However, I'm running into trouble with the Swagger integration if I try to deploy the Web API to an IIS Application (similar to a virtual directory). Previous answers I found have not provided a solution to the problem.
For example, the URL of the IIS Application is http://example.com/myapi
. Navigating to that URL should redirect to http://example.com/myapi/swagger
, but it redirects to http://example.com/swagger
instead, which doesn't exist. ServerRootAddress is set to http://example.com/myapi
in appsettings.json. This may be due to the following code in HomeController of the Web.Host project:
public IActionResult Index()
{
return Redirect("/swagger");
}
It appears to be hard-coded to the root of the web site, rather than using a relative path, but I'm not certain. If I modify the controller to use a relative path, the Swagger page will load, but I am not able to authenticate. It tries to navigate to http://example.com/api/TokenAuth/Authenticate
instead of http://example.com/myapi/api/TokenAuth/Authenticate
. Again, it is not using a relative path. Here is related code from abp.swagger.js:
xhr.open('POST', '/api/TokenAuth/Authenticate', true);
Is this a limitation of ABP or the Module Zero Core template, or is there some additional configuration I need to do in ABP, Swagger/Swashbuckle, or IIS to get this working? FWIW, the app is running on ABP version 3.8.