最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Why is the route with parameters not processed? - Stack Overflow

programmeradmin0浏览0评论

I just started practicing with ASP.NET Core, but I have already encountered a problem that I can't find a solution to for 3 hours. I wrote this simple code, but for some reason I can't process the route. The code in app.Map("/delete/{fileName}", (string fileName) => simply refuses to work.

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.Map("/delete/{fileName}", (string fileName) =>
{
    Console.WriteLine("middleware registered");
});

app.Run(async (context) =>
{
    var indexHtmlPage = app.Environment.ContentRootFileProvider.GetFileInfo("/FrontEnd/index.html");

    context.Response.ContentType = "text/html; charset=utf-8";
    await context.Response.SendFileAsync(indexHtmlPage);
});

app.Run();

I tried all the different options I could find, but they don't work. I just want to understand what's going on and solve the problem.

发布评论

评论列表(0)

  1. 暂无评论