-2

Here is my code, simple request, response HTTP;

    string uri = "https://forum.donanimhaber.com/forumid_12/tt.htm";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
        request.Method = WebRequestMethods.Http.Get;
        request.AllowAutoRedirect = false;
        request.CookieContainer = new CookieContainer();
        request.KeepAlive = true;
        request.ContentType = "application/x-www-form-urlencoded";
        request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream receiveStream = response.GetResponseStream();
        StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
        string oku = readStream.ReadToEnd();

if you go to this address and watch the network traffic at first get which is "tt.htm",at cookie section there is forum net id session cookie. i want to get this cookie's value in my program and i'm looking at web for this thing but none of them did work. thank you.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
Zeki Kral
  • 35
  • 2
  • 10
  • 1
    response.Cookies? – Gusman Aug 01 '17 at 17:29
  • yes but that shows me something else. not the cookie i want – Zeki Kral Aug 01 '17 at 17:37
  • What is the exact name of the cookie you are looking for? Is it coming from the same domain or third party site? – Eugene Komisarenko Aug 01 '17 at 17:38
  • ASP.NET_SessionId ?? – halit Aug 01 '17 at 17:39
  • yes halit i gotta get that cookie's value. exact name is "Forum.NET_SessionId" – Zeki Kral Aug 01 '17 at 17:41
  • donanimhaber sends seperate request to generate session. (like this) https://forum.donanimhaber.com/service/v1/session/set?version=-1&securekey=466386AE3F5F56EB1D9BE4DD46B78DC6&projectType=Forum&forumId=12 – halit Aug 01 '17 at 17:42
  • So what does it mean? should i request that url to get the cookie i want? – Zeki Kral Aug 01 '17 at 17:43
  • @ZekiKral Yes. You must send request to that url to generate sessionId – halit Aug 01 '17 at 17:44
  • i sent request to this address(which one you gave to me);https://forum.donanimhaber.com/service/v1/session/set?version=-1&securekey=466386AE3F5F56EB1D9BE4DD46B78DC6&projectType=Forum&forumId=12 and i added this code below of response; Console.WriteLine(response.Cookies.ToString()); it outputs "System.Net.CookieCollection" – Zeki Kral Aug 01 '17 at 17:50
  • because its a collection. try to loop it – halit Aug 01 '17 at 17:52
  • foreach (Cookie cook in response.Cookies) { Console.WriteLine("Domain: {0}, String: {1}", cook.Domain, cook.ToString()); } – halit Aug 01 '17 at 17:53
  • well i am kinda newbie. would you help me a little bit. i could learn how to loop but you are here and i don't want to lose you – Zeki Kral Aug 01 '17 at 17:53
  • ya siteyi mahvettin. biraz video eğitimleri falan izleyeydin . sil bu soruyu buradan işin bitince. – halit Aug 01 '17 at 17:55
  • https://i.hizliresim.com/r2agmz.png here what is outputs. as you can see its not what i need :( – Zeki Kral Aug 01 '17 at 17:55
  • tamam silerimde bir çözelim sabahtan beri uğraşıyorum deniyorum her şeyi olmuyor – Zeki Kral Aug 01 '17 at 17:56

1 Answers1

-2
        string uri = "https://forum.donanimhaber.com/service/v1/session/set?version=-1&securekey=123213&projectType=Forum&forumId=12";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
        request.Method = WebRequestMethods.Http.Get;
        request.AllowAutoRedirect = false;
        request.CookieContainer = new CookieContainer();
        request.KeepAlive = true;
        request.ContentType = "application/x-www-form-urlencoded";
        request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream receiveStream = response.GetResponseStream();
        StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
        string oku = readStream.ReadToEnd();


        foreach (Cookie cook in response.Cookies)
        {
            Console.WriteLine("Domain: {0}, Name: {1}, value: {2}", cook.Domain, cook.Name,cook.Value); 

        }
halit
  • 1,128
  • 1
  • 11
  • 27
  • https://i.hizliresim.com/WQyVY2.png isn't giving me the cookie's value i need. what is your output? – Zeki Kral Aug 01 '17 at 18:04
  • adamlar güvenlik önlemi almış olabilirler. securekey parametresinden birşeyleri kontrol ediyordur. Ip karşılaştırması gibi. – halit Aug 01 '17 at 18:07
  • ya yok almamışlardır. normal network trafficte gözüküyor işte ordan direk çekemiyor muyuz böyle alengirli işlere giriyoruz? hı? – Zeki Kral Aug 01 '17 at 18:09
  • benim kodu kopyala yapıştır çalışmıyorsa modemini bir kapat aç senin ip'yi engellemiş olabilirler. – halit Aug 01 '17 at 18:11
  • yaptım aynı hala düzelmiyor. Sende farklı mı çıkarıyor ekrana? – Zeki Kral Aug 01 '17 at 18:14
  • neyse bloklandım herhalde başka platformlardan da denerim. sende çalışıyorsa illaki çalışır son bir şey daha sen bu url'yi nerden çıkardın peki? – Zeki Kral Aug 01 '17 at 18:17
  • waooov get sonrasında veriyor onu. her gün yeni şeyler öğreniyoruz. siliyim mi soruyu? – Zeki Kral Aug 01 '17 at 18:31
  • silemiyorum başkaları cevap vererek emek harcadı diyor. özür dilerim votelar için – Zeki Kral Aug 01 '17 at 18:35