473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

question about WebClient.OpenRead


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");

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 6172
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·Transitional//EN">[LF]
<html>[LF]
<head>[LF]
··<title>Player·detection·in·Browser...</title>[LF]
[LF]
<script·language="JavaScript">[LF]
<!--[LF]
var·detectableWithVB·=·false;[LF]
var·quicktimeVersion·=·1;[LF]
[LF]
[LF]
function·createActiveXObject(id)·{[LF]
··var·error;[LF]
··var·control·=·null;[LF]
··try·{[LF]
····if·(window.ActiveXObject)·control·=·new·Active XObject(id);[LF]
····else·if·(window.GeckoActiveXObject)·control·=· new·GeckoActiveXObject(id)
;[LF]
····}[LF]
··catch·(error)·{·;·}[LF]
··return·control;[LF]
··}[LF]
//·-->[LF]
</script>[LF]
[LF]
[LF]
<script·language="VBscript">[LF]
[LF]
'do·a·one-time·test·for·a·version·of·VBScript·that·can·handl e·this·code'[LF]
detectableWithVB·=·False[LF]
quicktimeVersion·=·1[LF]
If·ScriptEngineMajorVersion·>=·2·then[LF]
··detectableWithVB·=·True[LF]
End·If[LF]
[LF]
'this·next·function·will·detect·most·plugins'[LF]
Function·detectActiveXControl(activeXControlName)[LF]
··on·error·resume·next[LF]
··detectActiveXControl·=·False[LF]
··If·detectableWithVB·Then[LF]
·····detectActiveXControl·=·IsObject(CreateObject( activeXControlName))[LF]
··End·If[LF]
End·Function[LF]
[LF]
'and·the·following·function·handles·QuickTime'[LF]
Function·detectQuickTimeActiveXControl()[LF]
··on·error·resume·next[LF]
··detectQuickTimeActiveXControl·=·False[LF]
··If·detectableWithVB·Then[LF]
····detectQuickTimeActiveXControl·=·False[LF]
····hasQuickTimeChecker·=·false[LF]
····Set·hasQuickTimeChecker·=·CreateObject("QuickT imeCheckObject.QuickTimeCh
eck.1")[LF]
····If·IsObject(hasQuickTimeChecker)·Then[LF]
······If·hasQuickTimeChecker.IsQuickTimeAvailable( 0)·Then·[LF]
········detectQuickTimeActiveXControl·=·True[LF]
········quicktimeVersion·=·CInt(Hex(hasQuickTimeCh ecker.QuickTimeVersion)·/·
1000000)[LF]
······End·If[LF]
····End·If[LF]
··End·If[LF]
End·Function[LF]
[LF]
</script>[LF]
[LF]
<script·type="text/javascript"·src="/includes/cookie_ops.js"></script>[LF]
<script·type="text/javascript"·src="/includes/player_detect.js"></script>[LF
]
[LF]
</head>[LF]
<body>[LF]
[LF]
[LF]
[LF]
<script>[LF]
var·lsMedia·=·new·Cookie(document,·"lsMedia",·0,·"/");[LF]
if·(canDetectPlugins())·{[LF]
··if·(detectQuickTime())·lsMedia.QT·=·quicktimeVer sion;[LF]
··if·(detectReal())·lsMedia.RP·=·"Y";[LF]
··if·(detectWindowsMedia())·{[LF]
····var·detectionResults·=·detectWMP();[LF]
····if·(detectionResults.installed)·lsMedia.pt·=·d etectionResults.typeOfPlay
er;[LF]
····lsMedia.WMP·=·(detectionResults.installed)·?·d etectionResults.versionInf
o·:·"Y";[LF]
····}[LF]
··}[LF]
else·lsMedia.detect·=·"none";[LF]
lsMedia.store();[LF]
</script>[LF]
[LF]
[LF]
[LF]
</body>[LF]
</html>[LF]


"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:RP**************@cpmsftngxa07.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******@online.microsoft.com> wrote in message
news:RP**************@cpmsftngxa07.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
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()...
11
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...
0
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()...
5
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: ...
1
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
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...
2
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...
4
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
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...

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.