3

我正在尝试解析string ResponseNameValueCollection如下所示:

public static NameValueCollection Request()
{
    // Snipped irrelevant code, so here's the string I get:
    string Response = "someparam=abcdef&another=123456";

    return HttpUtility.ParseQueryString(
        new Uri("http://1/?" + Response)
    .Query);
}

NameValueCollection Request = SomeClass.Request();
string SomeParam = Request.Get("someparam");
string Another = Request.Get("another");

但是我必须指定似乎是“错误的” http://1/?UriFormatException没有它就抛出a)。

我应该以不同的方式解决这个问题吗?

4

1 回答 1

6

你没有理由在Uri这里使用,只是HttpUtility.ParseQueryString(Response)应该这样做。

于 2013-04-10T08:53:10.013 回答