WebRequest
을 사용하여 HTML 사이트를 읽습니다. 서버가 내 요청을 리디렉션하고있는 것 같습니다.WebRequest - 리디렉션 방지
내 코드는 다음과 유사합니다
String URI = "http://www.foo.com/bar/index.html"
WebRequest req = WebRequest.Create(URI);
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
String returnedContent = sr.ReadToEnd();
나는 returnedContent
의 내용을 확인하는 경우가 http://www.foo.com/FOO_BAR/index "와 같은 재에서 콘텐츠가 포함되어 있습니다. html ". 수신 된 응답 (IFrame)의 일부이므로 요청한 URL이 존재한다고 확신합니다.
WebResponse
의 리디렉션을 방지하고 요청한 URL의 콘텐츠를 가져 오는 방법이 있습니까?
302 Found
상태 코드에 req.AllowAutoRedirect = false
리드를 설정 UPDATE
하지만 acutal 콘텐츠를 제공하지 않습니다.
일부 자세한 내용
:<body>
<div>
<iframe src="/foo/index.html"></iframe>
</div>
</body>
체크 아웃 http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.allowautoredi rect.aspx – Matthew