A set of technologies in the .NET Framework for building web applications and XML web services.
Hi @Peter Liang ,
Thanks for reaching out.
When you run:
https://localhost:7060/swagger/index.html
that’s using the development profile on your machine. Port 7060 is just a random development port assigned by Kestrel/IIS Express. It does not automatically exist on your IIS server.
On your server, you mentioned IIS is bound to HTTPS on port 443. For HTTPS, port 443 is the default, so accessing:
https://abc.com/
is the correct way to test the deployment (no need to specify :443).
Now the key issue: in your Program.cs, Swagger is wrapped inside:
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
When you deploy to IIS, the environment is typically Production unless you explicitly changed ASPNETCORE_ENVIRONMENT. That means Swagger is not enabled on the server. So when you try:
https://abc.com/swagger/index.html
a 404 - File not found is expected. It’s not a connectivity failure, Swagger simply isn’t being served in Production.
Here’s how to move forward:
Step 1: Test basic deployment
Try accessing:
https://abc.com/
You mapped:
app.MapGet("/", () => "Hello world!");
If you see “Hello world!”, then:
- DNS is correct
- IIS binding is correct
- The site is deployed correctly
- Only Swagger is disabled
If that works, your server is fine.
Step 2: If you want Swagger in Production
Move Swagger outside the development check:
app.UseSwagger();
app.UseSwaggerUI();
Or temporarily set the environment variable on the server to Development (not recommended long-term for security reasons).
Step 3: If root URL fails
If https://abc.com/ does not return “Hello world!”, then the issue is with IIS configuration. In that case, verify:
- The IIS site is pointing to the correct published folder
- The App Pool is running
- DNS (
nslookup abc.com) resolves to the correct server IP - Firewall allows inbound 443
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.