473,473 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to bypass website pops via HTTPWebRequest?

I'm checking a URL and logging the results returned from the server. One
problem is when a site ask for cookies, my code times out. For example, this
link does:
http://publications.mediapost.com/in...12097&p=261023

A cookie prompt causes the following code to timeout and jump into the
catch. This causes me to miss providing values to those variables after the
"Dim wResp" line. How can I make use of the cookie or get around it to get
the status return codes from the server?
Try
TraceLink.URLSource = url
Dim wReq As WebRequest = WebRequest.Create(url)
Dim CookieContainer1 As New CookieContainer
wReq.Timeout = 10000
If TypeOf wReq Is HttpWebRequest Then
CType(wReq, HttpWebRequest).UserAgent = "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; Feedreader; .NET CLR 1.1.4322; .NET
CLR 2.0.40607)"
CType(wReq, HttpWebRequest).CookieContainer =
CookieContainer1
End If
Dim wResp As HttpWebResponse = DirectCast(wReq.GetResponse(),
HttpWebResponse) 'timeout occurs here
TraceLink.Server_StatusCode = wResp.StatusCode
TraceLink.Server_StatusDescription = wResp.StatusDescription
TraceLink.Server_ContentType = wResp.ContentType
TraceLink.URLDestination =
wReq.GetResponse.ResponseUri.AbsoluteUri

Catch ex As Exception
TraceLink.Server_StatusDescription = ex.Message()
End Try

Thanks,
Brett
Nov 21 '05 #1
1 1750
This problem is related to a connection limit that is defaulted to 2 in the
HttpWebRequest object:
Dim objRequest As HttpWebRequest = WebRequest.Create(url)

In the watches window, the tree looks like this:
ObjRequest
ServicePoint
ConnectionLimit = 2
CurrentConnection2 = 2
The resolution was:
wResp.Close()

Must I have access to the server "url" is referencing to change the
connection limit? How exactly is it done?

Thanks,
Brett

"Brett" <no@spam.net> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl... I'm checking a URL and logging the results returned from the server. One
problem is when a site ask for cookies, my code times out. For example,
this link does:
http://publications.mediapost.com/in...12097&p=261023

A cookie prompt causes the following code to timeout and jump into the
catch. This causes me to miss providing values to those variables after
the "Dim wResp" line. How can I make use of the cookie or get around it to
get the status return codes from the server?
Try
TraceLink.URLSource = url
Dim wReq As WebRequest = WebRequest.Create(url)
Dim CookieContainer1 As New CookieContainer
wReq.Timeout = 10000
If TypeOf wReq Is HttpWebRequest Then
CType(wReq, HttpWebRequest).UserAgent = "Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; Feedreader; .NET CLR 1.1.4322; .NET
CLR 2.0.40607)"
CType(wReq, HttpWebRequest).CookieContainer =
CookieContainer1
End If
Dim wResp As HttpWebResponse = DirectCast(wReq.GetResponse(),
HttpWebResponse) 'timeout occurs here
TraceLink.Server_StatusCode = wResp.StatusCode
TraceLink.Server_StatusDescription = wResp.StatusDescription
TraceLink.Server_ContentType = wResp.ContentType
TraceLink.URLDestination =
wReq.GetResponse.ResponseUri.AbsoluteUri

Catch ex As Exception
TraceLink.Server_StatusDescription = ex.Message()
End Try

Thanks,
Brett

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jan | last post by:
For an educational program I use a webservice for acces to a central database on a remote server. The webservice is is being accessed over https. So far this worked fine on the computersystems in...
5
by: Tyler | last post by:
I am developing an application which will allow me to automatically sign into an external website. I can currently do a screen scrape using HTTPWEBREQUEST. However I want to just redirect to the...
3
by: Admin.TalkPC | last post by:
Hi people, I have now spent far too much time on this small problem, I am hopefully going to hand it over to you guys that are cleverer than I in this respect. Problem. I need to get all...
0
by: tom | last post by:
What I want to do is upload a zip file to an https website. The site itself uses secure File transport. Now webclient has the simplicity to upload a file, but I cannot attach the neccessary cert to...
0
by: barrybevel | last post by:
Hi, I'm trying to login to the www.vodafone.ie website using HttpWebRequest. It works fine with IE/Firefox and the .NET Web Control too, just not with my code. I think it's a redirect 302...
0
by: Rama Jayapal | last post by:
i use the following code to login to a website but i dont achieve my purpose can anybody help me on this //code to request the page webRequest = HttpWebRequest.Create(url) as...
8
by: MarkusJNZ | last post by:
Hi, I need to write some code to ensure that a website is still online. I was just going to write some code (Using System.NET webrequest) to retrieve the HTML from a website and if the length...
2
by: andrewwan1980 | last post by:
I have a problem with a child window using the parent's FORM to do a submission/post to open a new window. This is being blocked by IE7. This is happening when accessing an external website that is...
5
by: Rajkiran R.B. | last post by:
I want to log in to a website using C# code.. The main aim is to check whether the username and password I provide is correct or not. I used the following code bool somefunction() {...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.