Answer the question
In order to leave comments, you need to log in
How to get values from a GET request and output them to the console?
A GET request comes to my C# server
GET /index.html?id1=1&id2=2&id3=3&id4=4 HTTP/1.1
Host: localhost
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Answer the question
In order to leave comments, you need to log in
Is there a similarity to the Request class, like in ASP.NET? You can output through it.
Or it is stupidly possible to parse the first line of this request.
string n = "GET /index.html?id1=1&id2=2&id3=3&id4=4 HTTP/1.1";
string q = n.Split(new Char[] { ' ', '?' })[2];
foreach(string p in q.Split(new Char[] { '&' }))
{
System.Console.Write(p.Split(new Char[] { '=' })[1]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question