473,941 Members | 14,494 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 6241
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
2004
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
1451
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
1336
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
6507
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
2594
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
4373
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
892
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
9965
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11117
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...
0
10659
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9860
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
8218
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
7390
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
6299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4509
muto222
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.