简书链接:aspnetcoreapiMapGet指定html让其不转义
文章字数:28,阅读全文大约需要1分钟
这种情况下,无法填写html ,因为永远都会转义
app.MapGet("/", () => "This is a POST /swagger/index.html");
需要改为下面这种

1
2
3
4
5
app.MapGet("/", async context =>
{
context.Response.Headers.Add("Content-Type", "text/html");
await context.Response.WriteAsync("<a href=\"/swagger/index.html\">SWAGGER API</a><br/> ");
});