question

Orgbrat avatar image
0 Votes"
Orgbrat asked asifjan-0302 answered

Swagger UI page is blank on localhost IISExpress SSL URL

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

dotnet-aspnet-core-webapi
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.

Orgbrat avatar image
0 Votes"
Orgbrat answered Orgbrat commented

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

· 1
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.

AgaveJoe avatar image
0 Votes"
AgaveJoe answered

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";
 });



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.

Orgbrat avatar image
0 Votes"
Orgbrat answered AgaveJoe commented

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.

· 1
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.

I can't reproduce this issue without the code.

0 Votes 0 ·
ChaoDeng-MSFT avatar image
0 Votes"
ChaoDeng-MSFT answered

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


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.

asifjan-0302 avatar image
1 Vote"
asifjan-0302 answered

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,

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.