You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB
C#

namespace LaunchUrlStudy.SubSite1
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
//注册IoC容器
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// 配置请求管道
app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthorization();
app.MapControllers();
#region 配置启动地址(支持子站点):路由+重定向
//Map方法
app.Map("/", async context =>
{
context.Response.Redirect($"{context.Request.PathBase}/swagger/index.html");
await Task.CompletedTask;
});
//MapGet方法
//app.MapGet("/", async context =>
//{
// context.Response.Redirect("swagger/index.html");
// await Task.CompletedTask;
//});
//经典版或老版本写法
//app.UseEndpoints(endpoints =>
//{
// app.Map("/",async context =>
// {
// context.Response.Redirect("swagger/index.html");
// await Task.CompletedTask;
// });
//});
#endregion
app.Run();
}
}
}