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.
|
|
|
|
|
|
|
|
|
namespace LaunchUrlStudy.SubSite2
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
app.UseSwagger();
|
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
|
|
//配置启动地址(支持子站点):路由+自定义内容
|
|
|
|
|
app.MapGet("/", async context =>
|
|
|
|
|
{
|
|
|
|
|
//绝对Url
|
|
|
|
|
string swaggerUrl = Microsoft.AspNetCore.Http.Extensions.UriHelper.BuildAbsolute(context.Request.Scheme, context.Request.Host, context.Request.PathBase, "/swagger/index.html");
|
|
|
|
|
|
|
|
|
|
//相对Url
|
|
|
|
|
string swaggerUrl2 = Microsoft.AspNetCore.Http.Extensions.UriHelper.BuildRelative(context.Request.PathBase, "/swagger/index.html");
|
|
|
|
|
|
|
|
|
|
context.Response.ContentType = "text/html";
|
|
|
|
|
|
|
|
|
|
var wellcomHtml =
|
|
|
|
|
$"""
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="zh-CN">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
<title>{AppDomain.CurrentDomain.FriendlyName}</title>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div style="text-align:center">
|
|
|
|
|
<h2>{AppDomain.CurrentDomain.FriendlyName} 启动成功!</h2>
|
|
|
|
|
<h3>详情参阅:<a href="{swaggerUrl}">Swagger 文档</a></h3>
|
|
|
|
|
</div>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
""";
|
|
|
|
|
|
|
|
|
|
await context.Response.WriteAsync(wellcomHtml);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.Run();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|