- In the Visual Studio, create a new project: ASP.NET Core Web Application
- Select project template: API
- After the project is created follow instructions as below
https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-5.0&tabs=visual-studio - Add NuGet Package: Swashbuckle.AspNetCore
Modified startup.cs file as below
- Once is done, rebuild the project and debug
- When the page has opened up, navigate to /swagger
First deploy to the server
- Right-click on the project and publish
- Copy the Target Location
- Open IIS
- Create a new website
- Map the Physical Path to the Target Location
- Go to Application Pools
- Edit Application Pool
- Set .NET CLR version: No Managed Code
- Install ASP.NET Core 3.1 Runtime - Windows Hosting Bundle to the server
https://dotnet.microsoft.com/download/dotnet/3.1
If you haven't register the domain on public DNS, in order to view your Swagger page on you local machine, you should update hosts file on your machine.
To do so, open hosts file on the your machine at c:\Windows\System32\Drivers\etc
and append to the file content as:
[IP Address] [API domain name]
Example:
127.0.0.1 tech--about.com
No comments:
Post a Comment