How to redirect root to swagger in Asp.Net Core 2.x? (edit)
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory)
{
app.UseStartupService(env, applicationLifetime, configuration: Configuration, loggerFactory: loggerFactory);
app.UseProductionStartupService(env, applicationLifetime, Configuration);
app.UseCustomService(Configuration);
var option = new RewriteOptions();
option.AddRedirect("^$", "swagger");
app.UseRewriter(option);
app.UseMvc();
}
https://stackoverflow.com/questions/49290683/how-to-redirect-root-to-swagger-in-asp-net-core-2-x
In Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
before
app.UseMvc();
add
var option = new RewriteOptions(); option.AddRedirect("^$", "swagger"); app.UseRewriter(option);
Set default page (C#)
https://docs.microsoft.com/en-us/iis/configuration/system.webserver/defaultdocument/
Set default page for your website in Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="bin\IISSupport\VSIISExeLauncher.exe" arguments="-argFile IISExeLauncherArgs.txt" stdoutLogEnabled="false">
<environmentVariables />
</aspNetCore>
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
<directoryBrowse enabled="true" />
<defaultDocument>
<files>
<clear />
<add value="~/swagger/index.html" />
</files>
</defaultDocument>
</system.webServer>
</location>
</configuration>
How to set in Visual Studio Startup Page in web config
https://forums.asp.net/t/1934284.aspx?How+to+set+in+Visual+Studio+Startup+Page+in+web+config+