question

SachinKulkarni-1242 avatar image
0 Votes"
SachinKulkarni-1242 asked SachinKulkarni-1242 answered

Swagger not working in IIS

Hi,

Below is the code. I have hosted in IIS but I am getting 404 error. I have used double dot.
Configure

     services.AddSwaggerGen(c =>
             {
                  c.SwaggerDoc("v1", new OpenApiInfo { Title = "TestWebApi", Version = "v1" });
                    
                 //
                 c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                 {
                     In = ParameterLocation.Header,
                     Description = "Please insert JWT with Bearer into field",
                     Name = "Authorization",
                     Type = SecuritySchemeType.ApiKey
                 });
                 c.AddSecurityRequirement(new OpenApiSecurityRequirement {
    {
      new OpenApiSecurityScheme
      {
        Reference = new OpenApiReference
        {
          Type = ReferenceType.SecurityScheme,
          Id = "Bearer"
        }
       },
       new string[] { }
     }
             });
         });

ConfigureServices


  app.UseSwaggerUI(c => c.SwaggerEndpoint("../swagger/v1/swagger.json", "TestWebApi v1") 
                    
                 );


dotnet-aspnet-core-webapi
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can you run it without IIS? You can try to delete the .vs folder in project's file explorer first.

0 Votes 0 ·

Yes,

I can run without IIS in VS 2019.

0 Votes 0 ·

1 Answer

SachinKulkarni-1242 avatar image
0 Votes"
SachinKulkarni-1242 answered

I cannot see any vs folder

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.