Swagger UI page is blank on localhost IISExpress SSL URL

Orgbrat 116 Reputation points
2021-06-08T15:18:14.323+00:00

I am developing a v5.0.6 ASP.NET Core WebApi and included Swashbuckle.AspNetCore Swagger with SwaggerUI enabled. I am developing with Visual Studio 2019 v16.10.0 on Windows 10 Version 21H1 (OS Build 19043.1023). Settings within the project properties are:

IISExpress App URL: http://localhost:64870
IISExpress Enable SSL URL: https://localhost:44387/
Console http://localhost:5000 and http://localhost:5001
If I start the WebApi from VS2019 and it comes up with URL 'https://localhost:44387/' the SwaggerUI page is completely blank but the WebApi can be accessed and data can be retrieved So I know the WebApi is working as it should. I can access the WebApi from any of the other URLs and the SwaggerUI page is displayed as it should be. It is only the IISExpress SSL URL of 'https://localhost:44387/' that has the empty page. I have spent hours working on this issue with no solution.

But the URL localhost:44387/swagger/v1/swagger.json displays data for swagger as it should. It is only the UI that is not working on IISEXpress SSL.

Has anyone seen this issue and has a solution.

Steve

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,617 questions
0 comments No comments
{count} votes

Accepted answer
  1. Orgbrat 116 Reputation points
    2021-08-11T18:59:44.077+00:00

    Update: The latest version of Swashbuckle.AspNetCore Swagger v6.1.5 seeems to have fixed this issue.


4 additional answers

Sort by: Most helpful
  1. AgaveJoe 28,536 Reputation points
    2021-06-08T18:59:08.007+00:00

    Make sure your "launchUrl" setting in launchSettings.json are correct and matches your configuration. I use the standard Web API template of "swagger". Share your configuration if you still need help.

      "profiles": {
        "IIS Express": {
          "commandName": "IISExpress",
          "launchBrowser": true,
          "launchUrl": "swagger",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          }
        },
    
    app.UseSwaggerUI(c => {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApiDemo v1");
        c.RoutePrefix = "swagger";
    });
    
    1 person found this answer helpful.
    0 comments No comments

  2. asif jan 6 Reputation points
    2021-10-25T09:22:18.203+00:00

    I want to deploy API those , I developed in asp.net core 5. but unable to fix it.
    I have installed every thing but getting error on it

    https://www.yardim.pk

    Thanks,

    1 person found this answer helpful.
    0 comments No comments

  3. Orgbrat 116 Reputation points
    2021-06-08T22:13:24.543+00:00

    Well this line ' "launchUrl": "swagger",' was missing in my launchSettings.json and my c.RoutePrefix was set to string.empty. Everything else was exactly the same. I made those two changes and no chnages in SwaggerUI display. Evrthing thing works as it should other than a blank page when running on IISExpress SSL localhost URL.


  4. Chao Deng-MSFT 796 Reputation points
    2021-06-16T07:10:47.113+00:00

    Hi @Orgbrat ,
    Is your swagger middleware configured correctly?like this:

    public void ConfigureServices(IServiceCollection services)  
    {  
        // Register the Swagger generator, defining 1 or more Swagger documents  
        services.AddSwaggerGen(c =>  
        {  
            c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });                  
        });  
        services.AddControllers();  
    }  
    

    This adds the Swagger generator to the services collection.
    In the Configure() method, let’s enable the middleware for serving the generated JSON document and the Swagger UI:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)  
    {  
        // Enable middleware to serve generated Swagger as a JSON endpoint.  
        app.UseSwagger();  
        // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),  
        // specifying the Swagger JSON endpoint.  
        app.UseSwaggerUI(c =>  
        {  
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");  
        });  
    }  
    

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    ChaoDeng

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.