473,830 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question about WebClient.OpenR ead


Hi,

I don't know if this is the correct place to post this but i am having a
little problem with the OpenRead function of the WebClient.

Below is the code i am trying to get it to work:
WebClient Client = new WebClient();
Stream strm = Client.OpenRead ("http://something.jsp?u ser=username");

If i simply put the url above into internet explorer i will get a valid page
that i can parse through however if i try to do this using the OpenRead
function i get an internal server error 500. Any ideas why this might happen
?

Thank You
Jul 21 '05 #1
5 6226
Seymen Ertas wrote:
Hi,

I don't know if this is the correct place to post this but i am having a
little problem with the OpenRead function of the WebClient. If i simply put the url above into internet explorer i will get a valid page
that i can parse through however if i try to do this using the OpenRead
function i get an internal server error 500. Any ideas why this might happen


Go to the web server and find what the error is.
Also you can try to compare queries by using network sniffer.

Vadim Chekan.

Jul 21 '05 #2
Hi,

Thanks for your post. WebClient class is used to send and receive data from
a resource identified by a URI. We cannot get .jsp result with WebClient,
instead we are able to use the HttpWebRequest and HttpWebResponse classes
to send HTTP requests and get the result like in IE. Please refer to the
following sample:

SAMPLE: Visual C# .NET Networking Classes HTTP Internet Client
http://support.microsoft.com/?id=303436

Please let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3
Hi Tian,

Thank You for your response, upon doing more investigation i believe my
problem is due to a check that occurs after i try to open .jsp page and
before the final html code is generated, what seems to be happening is this
page first tries to check if a player is available and i believe when it's
not (using HttpWebResponse .GetResponse) it gives me an exception (500)

Is there a way for me to fake the request so that it looks like i have the
player installed ? All i am really interested in is getting the final html
generated by the server ?

Thank You

Below is the output obtained from web-sniffer.net after typing in the URL:

<!DOCTYPE·HTML· PUBLIC·"-//W3C//DTD·HTML·4.01·T ransitional//EN">[LF]
<html>[LF]
<head>[LF]
··<title>Player ·detection·in·B rowser...</title>[LF]
[LF]
<script·languag e="JavaScript ">[LF]
<!--[LF]
var·detectableW ithVB·=·false;[LF]
var·quicktimeVe rsion·=·1;[LF]
[LF]
[LF]
function·create ActiveXObject(i d)·{[LF]
··var·error;[LF]
··var·control·= ·null;[LF]
··try·{[LF]
····if·(window. ActiveXObject)· control·=·new·A ctiveXObject(id );[LF]
····else·if·(wi ndow.GeckoActiv eXObject)·contr ol·=·new·GeckoA ctiveXObject(id )
;[LF]
····}[LF]
··catch·(error) ·{·;·}[LF]
··return·contro l;[LF]
··}[LF]
//·-->[LF]
</script>[LF]
[LF]
[LF]
<script·languag e="VBscript">[LF]
[LF]
'do·a·one-time·test·for·a ·version·of·VBS cript·that·can· handle·this·cod e'[LF]
detectableWithV B·=·False[LF]
quicktimeVersio n·=·1[LF]
If·ScriptEngine MajorVersion·>= ·2·then[LF]
··detectableWit hVB·=·True[LF]
End·If[LF]
[LF]
'this·next·func tion·will·detec t·most·plugins'[LF]
Function·detect ActiveXControl( activeXControlN ame)[LF]
··on·error·resu me·next[LF]
··detectActiveX Control·=·False[LF]
··If·detectable WithVB·Then[LF]
·····detectActi veXControl·=·Is Object(CreateOb ject(activeXCon trolName))[LF]
··End·If[LF]
End·Function[LF]
[LF]
'and·the·follow ing·function·ha ndles·QuickTime '[LF]
Function·detect QuickTimeActive XControl()[LF]
··on·error·resu me·next[LF]
··detectQuickTi meActiveXContro l·=·False[LF]
··If·detectable WithVB·Then[LF]
····detectQuick TimeActiveXCont rol·=·False[LF]
····hasQuickTim eChecker·=·fals e[LF]
····Set·hasQuic kTimeChecker·=· CreateObject("Q uickTimeCheckOb ject.QuickTimeC h
eck.1")[LF]
····If·IsObject (hasQuickTimeCh ecker)·Then[LF]
······If·hasQui ckTimeChecker.I sQuickTimeAvail able(0)·Then·[LF]
········detectQ uickTimeActiveX Control·=·True[LF]
········quickti meVersion·=·CIn t(Hex(hasQuickT imeChecker.Quic kTimeVersion)·/·
1000000)[LF]
······End·If[LF]
····End·If[LF]
··End·If[LF]
End·Function[LF]
[LF]
</script>[LF]
[LF]
<script·type="t ext/javascript"·src ="/includes/cookie_ops.js"> </script>[LF]
<script·type="t ext/javascript"·src ="/includes/player_detect.j s"></script>[LF
]
[LF]
</head>[LF]
<body>[LF]
[LF]
[LF]
[LF]
<script>[LF]
var·lsMedia·=·n ew·Cookie(docum ent,·"lsMedia", ·0,·"/");[LF]
if·(canDetectPl ugins())·{[LF]
··if·(detectQui ckTime())·lsMed ia.QT·=·quickti meVersion;[LF]
··if·(detectRea l())·lsMedia.RP ·=·"Y";[LF]
··if·(detectWin dowsMedia())·{[LF]
····var·detecti onResults·=·det ectWMP();[LF]
····if·(detecti onResults.insta lled)·lsMedia.p t·=·detectionRe sults.typeOfPla y
er;[LF]
····lsMedia.WMP ·=·(detectionRe sults.installed )·?·detectionRe sults.versionIn f
o·:·"Y";[LF]
····}[LF]
··}[LF]
else·lsMedia.de tect·=·"none";[LF]
lsMedia.store() ;[LF]
</script>[LF]
[LF]
[LF]
[LF]
</body>[LF]
</html>[LF]


"Tian Min Huang" <ti******@onlin e.microsoft.com > wrote in message
news:RP******** ******@cpmsftng xa07.phx.gbl...
Hi,

Thanks for your post. WebClient class is used to send and receive data from a resource identified by a URI. We cannot get .jsp result with WebClient,
instead we are able to use the HttpWebRequest and HttpWebResponse classes
to send HTTP requests and get the result like in IE. Please refer to the
following sample:

SAMPLE: Visual C# .NET Networking Classes HTTP Internet Client
http://support.microsoft.com/?id=303436

Please let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4
Hi Tian,

I think i am starting to understand this a little better, what seems to
happen is the first time i call the jsp page a sessionid is generated for me
i need to be able to read this session id in order to get the final html
page that i am looking for.

so my current problem is being able to successfully read the new link which
has a session id in it that is generated as a result of the first jsp page.

Thank You (hopefully you will be bear with me on this :-) )
"Tian Min Huang" <ti******@onlin e.microsoft.com > wrote in message
news:RP******** ******@cpmsftng xa07.phx.gbl...
Hi,

Thanks for your post. WebClient class is used to send and receive data from a resource identified by a URI. We cannot get .jsp result with WebClient,
instead we are able to use the HttpWebRequest and HttpWebResponse classes
to send HTTP requests and get the result like in IE. Please refer to the
following sample:

SAMPLE: Visual C# .NET Networking Classes HTTP Internet Client
http://support.microsoft.com/?id=303436

Please let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5
Hi,

Thanks for your information. I am very glad to hear that you resolved the
problem!

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #6

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

Similar topics

0
1998
by: Helen Abell | last post by:
Hi, I am trying to use a .Net WebClient object to read data from a url, but I am getting the following error: System.Net.HttpWebRequest.CheckFinalStatus() System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) System.Net.HttpWebRequest.GetResponse() System.Net.WebClient.OpenRead(String address)
11
942
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred during a webclient request" .._Hresult = "-2146233079" .._COMPlusExceptionCode ="-532459699" Sorry I don't have the whole error, but this seems to be the only pertinent
0
1446
by: Helen | last post by:
Hi, I am trying to use a .Net WebClient object to read data from a url, but I am getting the following error: System.Net.HttpWebRequest.CheckFinalStatus() System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) System.Net.HttpWebRequest.GetResponse() System.Net.WebClient.OpenRead(String address)
5
307
by: Seymen Ertas | last post by:
Hi, I don't know if this is the correct place to post this but i am having a little problem with the OpenRead function of the WebClient. Below is the code i am trying to get it to work: WebClient Client = new WebClient(); Stream strm = Client.OpenRead("http://something.jsp?user=username");
1
1330
by: chris.dannemiller | last post by:
I have a connection through WebClient running via a thread. Then I call a .OpenRead(). I would like the main thread to be able to cancel this connection. How do I go about it.
1
6501
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config <authentication mode="Windows" /> and set up IIS to not allow anonymous access. My browser is set up to auto detect the proxy server, so IE/Firefox can access outside pages, so I added code to auto-detect the proxy server.
2
2586
by: Ezequiel | last post by:
Hi, I´m coding an application that is able to download various mp3 files at the same time. For each mp3 download i´m using a thread. Each thread uses System.net.WebClient. If i try to download 3 files at the same time, 2 of them starts downloading (i see in the explorer the size incresing with the time) however the third mp3 never starts downloading and after some seconds, application throws a timeout exception in the ...
4
4367
by: Harvey Triana | last post by:
Hi- I am using... WebClient Client = new WebClient (); Client.DownloadFile(url, filename); Or Stream strm = Client.OpenRead (url);
0
889
by: Xavier Mauclaire | last post by:
Hi I've got a piece of code using the webclient object (see below). This function was working until i installed the . Net 3.0 on my computer. This code run withs the version 2.0 of the dotnet Framework. After this installation, the OpenRead functiuon generate an error. "Can't open a session, wring username or password". Or Creadentials informations are good.
0
9793
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10489
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9314
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6950
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.