0

I'm having a little trouble implementing Swagger on an existing .NET 4.8 WebApi.

Using VS2019 I have used Nuget Package Manager to install Swashbuckle 5.6.0, it has added SwaggerConfig.cs into the App_Start folder. I have left this file stock-standard.

Online examples seem to imply that it should now run. I am running it locally in debug. I start the service, which by default goes to http://localhost:53374/about2.aspx. Once there I alter the URL to http://localhost:53374/swagger/.

That when I get the following error:

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

Things tried:

  • deleting the .vs folder
  • checking for a Swagger folder under the root, result: nothing
  • tried altering the URL to: http://localhost:53374/swagger/ui/index, no luck

I haven't enabled directory browsing as I don't think that is what this needs, as I tested a simple core API project with Swagger and it worked without this.

What else could I try? Any ideas are most welcome.

Could it be that Swagger needs some type of authorization?

Helen
  • 87,344
  • 17
  • 243
  • 314
Hank
  • 2,456
  • 3
  • 35
  • 83
  • Swagger generates json file which loads in swagger ui and from that json file all UI is generated. So swagger needs access to directory to load json file. Or you can try and add that generated json to Default documents ?! – J.Memisevic Jul 01 '22 at 04:21
  • Thanks J, that makes sense. So if VS is running IISExpress while I am in debug mode and IIS Manager is not installed, is there a way to avoid making settings in IIS/IIS Express and provide some swagger configuration to write to a particular folder within the project? Just unsure how to proceed. – Hank Jul 01 '22 at 04:35
  • I think that u can change the location where json file will be saved . U can try this https://stackoverflow.com/questions/41022875/change-location-of-swagger-json-using-swashbuckle . Btw are u running your VS on your local machine ? – J.Memisevic Jul 01 '22 at 05:41
  • I am running locally yes, but eventually these changes will get pushed up to our Azure dev environment – Hank Jul 01 '22 at 05:43
  • Hmm that looks particularly like a Core solution rather than .Net 4.8, but I will try and find something similar in my SwaggerConfig.cs file – Hank Jul 01 '22 at 05:52

0 Answers0