当我在IIS上部署Swagger UI时,它显示404错误



我有一个带有vue.js的asp.net核心应用程序。我制作了web api。当我通过localhost进行调试时,一切都很好。Swagger UI正在工作,同时也是应用程序。但当我将应用程序部署到IIS时,Swagger不起作用,并显示404错误。

以下是Startup.cs 中的招摇配置

services.AddSwaggerGen(config =>
{
var xmlFile = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
config.IncludeXmlComments(xmlPath);
});
app.UseSwagger(options =>
{
options.SerializeAsV2 = true;
options.RouteTemplate = "info/swagger/{documentname}/swagger.json";
});
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/info/swagger/v1/swagger.json", "v1");
options.RoutePrefix = "info/swagger";
});

我该怎么办?将SwaggerEnpoint更改为"/info/swager"不要帮忙。我需要使用asp.net核心应用程序,也需要在IIS上大摇大摆。

出现问题

app.UseSwagger(options =>
{
options.SerializeAsV2 = true;
});
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/applicationName/swagger/v1/swagger.json", "v1");
options.RoutePrefix = "info/swagger";
});

删除选项。RouteTemplate并替换";信息";关于";appName"在选项中。SwaggerEndpoint帮助我。

相关内容

最新更新