首页 > 解决方案 > .NET 核心路由使用查询参数值

问题描述

我有带有不同值的查询参数的 URL

example.com/api/v1?op=getstudent

example.com/api/v1?op=getteacher

有没有办法下定 决心 example.com/api/v1?op=getstudent去行动getstudentexample.com/api/v1?op=getteachergetteacher

我尝试使用:

app.UseEndpoints(endpoints => {
    endpoints.MapGet("/webhdfs/v1/{path}", async context => {
        string opvalue = context.Request.Query["op"].ToString();
        // return specific action 
    });
});

我正在使用.NET 5.0

谢谢您的帮助

标签: c#.netroutes

解决方案


推荐阅读