First, you need to remove the swagger launch setting. Got to the Properties folder and open the launchSettings.json file, remove or clear the launchUrl property.

Then, you can create a wwwroot folder and add the default page: in the default page, you can add a hyperlink to navigate to the swagger UI.

After that, add the following code to the Configure method (if you are using Asp.net 6, you can add them in the Program.cs file):
app.UseHttpsRedirection();
var options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
app.UseRouting();
Finally, running the API application, the result as below:

Besides, if you are using the MVC view, you could refer to the following steps:
[Note] By using this method, still need to remove the launch setting relates the swagger.
Add a HomeController with Index Action.
Add an Index View page
Register the controller and view service in the ConfigureServices:
services.AddControllersWithViews();
Configure the endpoint
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapControllerRoute(name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
Then, when running the API application, it will show the Home Controller Index View page.