I have an asp.net core application with vue.js. I made web api. And when I'm debugging via localhost - everything is fine. Swagger UI is working, also as application. But when I deploy app to the IIS, Swagger don't work and show 404 error.
Here is swagger configuration in 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";
});
What should I do? changing SwaggerEnpoint to "../info/swager....." don't help. I need to working asp .net core app and also swagger on IIS.
The problem was in
app.UseSwagger(options =>
{
options.SerializeAsV2 = true;
});
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/applicationName/swagger/v1/swagger.json", "v1");
options.RoutePrefix = "info/swagger";
});
removing options.RouteTemplate and replace "info" on "appName" in options.SwaggerEndpoint helps me.