Use swagger (Swashbuckle ) with ASP.NET core 2.2 and IIS virtual applications
See original GitHub issueHi,
I’m currently testing the integration between ASP.NET core and swagger by using the Swashbuckle.AspNetCore nuget package.
My current test environment is the following:
- ASP.NET core 2.2 web application with one api controller
- the development machine is a windows 10 machine
- the installed version of IIS is IIS 10
I’m testing my application by using a virtual application under the IIS default web site. The virtual application has an alias of test-swagger. By following the documentation I configured the swagger middleware in the following manner (notice the . (dot) character at the beginning of the swagger endpoint):
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("./swagger/v1/swagger.json", "My API V1");
});
By configuring swagger this way the swagger UI does not work as expected, a pop-up is showed when the path /swagger is called and the message showed states that the swagger UI is not able to find the swagger.json file.
By following this blog I finally solved my issue. Basically, the only difference is that two . (dot) characters are required in the swagger endpoint configuration (while the official docs reports that just one dot character must be used in the swagger endpoint as a prefix).
To summarize, the working configuration for me is the following (notice the two . (dot) characters at the beginning of the swagger endpoint):
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("../swagger/v1/swagger.json", "My API V1");
});
Is there an error in the official docs ? Am I missing something ?
Thanks for helping !
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:9 (4 by maintainers)

Top Related StackOverflow Question
I’ll try to open an issue directly to Swashbuckle, by referencing this issue. I’ll write here in case of news
Hi and apologize for the late reply,
the full absolute URL to which I would like to see the swagger UI is
http://localhost/test-swagger/swagger/index.htmlwheretest-swaggeris the alias assigned to the application registered under the existing web site in IIS. The corresponding URL at which I would expect to find theswagger.jsonfile ishttp://localhost/test-swagger/swagger/v1/swagger.json.In this example I have the default IIS website registered to respond at port
80of localhost and I have registered an application under the default website using the aliastest-swagger, as explained above.These are the steps to reproduce the issue:
Swashbuckle.AspNetCoreapp.UseSwaggerUI(c => { c.SwaggerEndpoint("./swagger/v1/swagger.json", "My API V1"); });test-swaggerfor the application. Configure the application so that it uses a proper application pool able to run asp.net core applications as documented here.dotnet publish -c Releaseand deploy the binaries for the test application in the location chosen for the IIS application configured at the previous pointhttp://localhost/test-swagger/swagger/index.html. You will get an error when the swagger UI is rendered in your browser.