I\'m using HttpListener to provide a web server to an application written in another technology on localhost. The application is using a simple form submission (application/x-w
If you want to avoid the dependency on System.Web that is required to use HttpUtility.ParseQueryString, you could use the Uri
extension method ParseQueryString
found in System.Net.Http
.
Make sure to add a reference (if you haven't already) to System.Net.Http
in your project.
Note that you have to convert the response body to a valid Uri
so that ParseQueryString
(in System.Net.Http
)works.
string body = "value1=randomvalue1&value2=randomValue2";
// "http://localhost/query?" is added to the string "body" in order to create a valid Uri.
string urlBody = "http://localhost/query?" + body;
NameValueCollection coll = new Uri(urlBody).ParseQueryString();