I am trying to use Swagger with Web API. I am just using the "Azure API App" template from the ASP.NET 4.6 templates installed with Visual Studio, which includes the Swashbuckle.Core
and the SwaggerConfig.cs
. The API works fine (I am able to call it successfully), but if I try to go to "http://mybaseurl/swagger/", I get this error:
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
It seems like Swagger is not getting loaded or something. Anyone else get this before? I can't seem to get around this. Thank you, and please let me know if I can provide more details.
Here is what my SwaggerConfig.cs looks like:
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace With.Api
{
public class SwaggerConfig
{
public static void Register(HttpConfiguration config)
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
config.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "With.Api");
})
.EnableSwaggerUi();
}
}
}
I just had the same problem. It worked fine when I deployed my app to Azure, but when I started it locally, Swagger just wouldn't show up just as described above. Reverting to a previous version I knew was working before also didn't help, so it seemed to have something to do with IIS express. I'm not entirely sure what was causing the issue (I had changed some SSL related settings), but when I deleted the .vs folder (which contains the applicationhost.config file) and restarted Visual Studio, it started working again.