如何在MVC中将URL作为查询字符串参数传递

Raj*_*Raj 3 c# asp.net-core-mvc asp.net-core

有谁知道如何传递URL作为查询字符串参数,然后在HttpGet方法中获取URl作为参数?

Raj*_*Raj 5

非常感谢所有答案.最后我把它分类了.请参阅下面的我的修复:

[Route("api/[controller]")]
public class UrlController : Controller
{
    [HttpGet("{*longUrl}")]
    public string ShortUrl(string longUrl)
    {
        var test = longUrl + Request.QueryString;

        return JsonConvert.SerializeObject(GetUrlToken(test));
    }
Run Code Online (Sandbox Code Playgroud)