Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3695770
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:39:29+00:00 2026-05-19T04:39:29+00:00

I have a problem obtaining Location header from the WebResponse: private CookieContainer _cookieContainer =

  • 0

I have a problem obtaining Location header from the WebResponse:

private CookieContainer _cookieContainer = new CookieContainer();
...
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);

webRequest.Method = "POST";          
webRequest.Referer = "www.xxxxx.sk";            
webRequest.Proxy = GetSystemProxy();
webRequest.AllowAutoRedirect = false;
webRequest.CookieContainer = _cookieContainer;
webRequest.ContentType = "application/x-www-form-urlencoded";                                
webRequest.KeepAlive = false;            
//webRequest.Expect = "Location";

When i use Tamper data plugin in Firefox – I get what I want:

Location=http://www.xxxxx.sk?i9=3522a42d0207

But looking at HttpWebResponse.Headers does not contain this header (although 90 % of received headers are the same as in case of firefox)

I’ve tried to set .Expect to force the server to provide me that header, but I got error 417 Expectation failed.

The reason why I want that header is, that there is a session id in it, which I do need for further requests (Website has double security – cookies + session ID’s in URL)

What I do not understand is that by default HttpWebRequest will follow redirects, so if a server sends 301/302 status code a new request will be issued to fetch the resource using the Location header. So once this final resource is fetched there will no longer be a Location header in the response. But If I set AllowAutoRedirect to false, why doesn’t the header appear?

EDITED: Headers:

Mozilla request headers:


Host=prihlasenie.azet.sk
User-Agent=Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language=en-us,en;q=0.5
Accept-Encoding=gzip,deflate
Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive=115
Connection=keep-alive
Referer=http://www.azet.sk/
Content-Type=application/x-www-form-urlencoded
Content-Length=64
POSTDATA=form%5Busername%5D=yyyyyyyyyy&form%5Bpassword%5D=zzzzzzzzzz
--
Mozilla response headers:



Status=Found - 302
Date=Fri, 14 Jan 2011 13:12:37 GMT
Server=Apache
Pragma=no-cache
Expires=Fri, 14 Jan 2011 13:12:37 +0000
Cache-Control=post-check=0, pre-check=0, no-cache, must-revalidate
Set-Cookie=AZetSecId=3a2f118910; expires=Fri, 28-Jan-2011 13:12:37 GMT; path=/; domain=.azet.sk
Location=http://www.azet.sk/?i9=6ffcf488a877
Vary=User-Agent,Accept-Encoding
X-Served-By=prihlasenieweb-04
Content-Encoding=gzip
Content-Length=1124
Keep-Alive=timeout=15, max=82
Connection=Keep-Alive
Content-Type=text/html

--
------------------------------------------------
---
HttpWebRequest headers:

{Referer: http://www.xxxx.sk
Content-Type: application/x-www-form-urlencoded
Host: prihlasenie.xxxx.sk
Content-Length: 59
Expect: 100-continue
Connection: Close
}

and I'm doing:

byte[] paramBytes = Encoding.ASCII.GetBytes(postParameters);
webRequest.ContentLength = paramBytes.Length;

using (Stream requestStream = webRequest.GetRequestStream())
{
    requestStream.Write(paramBytes, 0, paramBytes.Length);
}
---
HttpWebResponse headers:

{Pragma: no-cache
Vary: User-Agent,Accept-Encoding
X-Served-By: prihlasenieweb-05
Connection: close
Content-Length: 2113
Cache-Control: post-check=0, pre-check=0, no-cache, must-revalidate
Content-Type: text/html
Date: Thu, 13 Jan 2011 20:56:21 GMT
Expires: Thu, 13 Jan 2011 20:56:21 +0000
Set-Cookie: xxxxSecId=b425262c2e; expires=Thu, 27-Jan-2011 20:56:21 GMT; path=/; domain=.xxxx.sk
Server: Apache
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:39:30+00:00Added an answer on May 19, 2026 at 4:39 am

    The problem lays within the initialization of the cookies since the webserver may rely on them to start the authentication process.

    Extra note: please add (http) cookie in the tags (“http-headers” one covers it but it’s too a global tag)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.