C#将所有参数作为单个字符串

Sta*_*hil 0 c# parameters asp.net-mvc

说我有这个网址:

url/myurl?param1=1&param2=2&param3=3&param4=4
Run Code Online (Sandbox Code Playgroud)

是否有可能获得填充字符串,"param1=1&param2=2&param3=3&param4=4"所以我可以传递它?

string data = *GetAllParams()*
Run Code Online (Sandbox Code Playgroud)

我知道Request.QueryString将返回所有参数,但我宁愿不循环遍历所有参数并将其添加到字符串中,如果我可以避免它.

Hab*_*bib 7

使用Uriclass和use Uri.Query属性来获取参数:如:

Uri uri = new Uri("http://example.com/myurl?param1=1&param2=2&param3=3&param4=4");
Console.WriteLine(uri.Query);
Run Code Online (Sandbox Code Playgroud)