我需要在ASP.NET中的文本框中获取"uxfuthorization"标记值。我使用curl将json请求发送到服务器,并从服务器获得以下响应。我希望"uxfuthorization"键值在文本框中,这样用户就可以查看授权密钥。
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Date: Tue, 08 Dec 2015 15:16:45 GMT
Pragma: no-cache
Content-Length: 22
Content-Type: application/json
Expires: -1
SET-COOKIE:WIRELESS_SECURITY_TOKEN=HvsvzzAyux0oXBENeLPwtQ**___currentencryptionkey___36wByp bpGkrOz/CQ6pTbGt44O+PpWvB0gu8hr12vIYa32j2Qg3Na3eylq5h4dZLeAmA6T6kZ4hevGJUjqXeFN8 2DIyEdaO7MVEqiemiGB90F7J0KXfiUdRjw5E5XkV9a; path=/; HttpOnly;
uxf_lastLoginDate: 1449587736928
uxfauthorization:UXF_CSRFToken:csrfcurrentencryptionkey___dpU+veeOOvcV/0mrZKt3V8c4tI677cvo0hodpmXppOQ= UXF_SessionToken:HvsvzzAyux0oXBENeLPwtQ==___currentencryptionkey___36wBypbpGkrOz/CQ6pTbGt44O+PpWvB0gu8hr12vIYa32j2Qg3Na3eylq5h4dZLeAmA6T6kZ4hevGJUjqXeFN82DIyEdaO7MVEqiemiGB90F7J0KXfiUdRjw5E5XkV9a
X-XSS-Protection: 1; mode=block
X-Powered-By: Servlet/3.0 JSP/2.2
{"__EmptyObject__":{}}
提前感谢。
您可以使用正则表达式解析文本中的值。它可以是如下所示:
String pattern = @"uxfauthorization:(.*?)";
Regex re = new Regex(pattern);
MatchCollection matches = re.Matches(your_curl_response_here);
foreach(Match match in matches){
// use the match.ToString() for your need
}