我想用Swagger和Web API一起使用。我只是使用随Visual Studio一起安装的ASP.NET 4.6模板中的“Azure API App”模板,其中包括Swashbuckle.Core
和SwaggerConfig.cs
。该API工作正常(我能成功地称呼它),但如果我尝试去“http://mybaseurl/swagger/”,我得到这个错误:Swagger给我HTTP错误403.14 - 禁止
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
好像扬鞭是没有得到加载或东西。其他人之前得到这个?我似乎无法解决这个问题。谢谢,请让我知道我是否可以提供更多细节。
这里是我的SwaggerConfig.cs是什么样子:
[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();
}
}
}
尝试启用'目录Browsing'在IIS本网站。 – Martin
没有运气。该文件夹实际上并不存在,路由器应该将我路由到swagger-ui –
您可以通过导航到swagger/docs或swagger/{version}/docs来获取json转储吗? –