Using the webbrowser object to get the document text

K

Kai Wiechers

Hello,
i try to use the content of the document loaded in the webbrowser object.
normaly webbrowser.documenttext would work fine, but in the CF it is write
onely :(
The Backround:
I build a string with a get request and call this url with the browser. the
result of my request is shown in the browser. and i want to use this answer
of the server.
i also tryed webrequest.create and on vista it worked fine, but on my
windows mobile device he only opend the GPRS connection. than i wait about 1
minute an than i gat a error. i cant tell the specific errortext beacuase it
is not shown on my device and in the emulator it doesn't work because im to
stupid do config it for internet access... so maybe somebody can help me
out? my prefered solution would be to go on using the webbrowser and getting
the information out of there. but i'm open to any other solution! thanks a
lot! i hope u can understand my english... ;)
 
C

chris-s

Hello,
i try to use the content of the document loaded in the webbrowser object.
normaly webbrowser.documenttext would work fine, but in the CF it is write
onely :(
The Backround:
I build a string with a get request and call this url with the browser. the
result of my request is shown in the browser. and i want to use this answer
of the server.
i also tryed webrequest.create and on vista it worked fine, but on my
windows mobile device he only opend the GPRS connection. than i wait about 1
minute an than i gat a error. i cant tell the specific errortext beacuase it
is not shown on my device and in the emulator it doesn't work because im to
stupid do config it for internet access... so maybe somebody can help me
out? my prefered solution would be to go on using the webbrowser and getting
the information out of there. but i'm open to any other solution! thanks a
lot! i hope u can understand my english... ;)

It may not be practical for your situation, but why not use
'WebServices' instead? This sounds like the sort of thing they were
designed for.

Cheers

Chris
 
K

Kai Wiechers

Hi,
thank you for your answer. i googled for the .net webservices and tryed to
use this solution in a test application, but when i tryed to add a
webservice via "project => "add webservice" visual studio didn't accepted ma
"http://gateway.sms77.de/?" as web service url.
my task is normaly not very difficult. i do a http GET request and need the
answer wich is for example 100 oder 301 or... what ever. i just need this 3
nubers. thay are displayed in the webbrowser after calling the url that i
created. for example i open
http://gateway.sms77.de/u=benutzer&...ne erste nachricht&type=quality&from=sms77.de
and i get back 100 in the webbrowser. i yust need this 100 in a string or
integer to go on working with that feedback state. as mentioned webrequest
worked fine with a normal windows application running on vista, but using
the same code on my PPC... i get a error.
is there any other posibility to get this GET request result? Thanks a lot!
 
K

Kai Wiechers

I just recognized that the answer to my http GET request is just a text
file. is there a posibility to download this text file? i tryed
webclient.downloadfile, but in the compact framework that doesn't work...
this could be a solution for my problem. so if there is any posibility to
download a file using the compact framework please tell me! thanks!
 
J

Jeff Newman

I just recognized that the answer to my http GET request is just a text
file. is there a posibility to download this text file? i tryed
webclient.downloadfile, but in the compact framework that doesn't work...
this could be a solution for my problem. so if there is any posibility to
download a file using the compact framework please tell me! thanks!

You can just open a TCP connection to the web server on port 80 using
TcpClient or a Socket. Send a command like "GET /index.html HTTP/1.1\r
\n\r\n" (*), and be sure to convert the text to ASCII before sending.
Then read your file off the socket.

(*)
I'm pretty sure most web server's will be happy with just a GET line,
but you might need a more properly formed HTTP request message with
some headers. You should be able to find that on google easily enough.
 
K

Kai Wiechers

I'll try that. Thank you!


Jeff Newman said:
You can just open a TCP connection to the web server on port 80 using
TcpClient or a Socket. Send a command like "GET /index.html HTTP/1.1\r
\n\r\n" (*), and be sure to convert the text to ASCII before sending.
Then read your file off the socket.

(*)
I'm pretty sure most web server's will be happy with just a GET line,
but you might need a more properly formed HTTP request message with
some headers. You should be able to find that on google easily enough.
 
P

Peter Foot [MVP]

Using the HttpWebRequest/HttpWebResponse approach you can use the
GetResponseStream method. Using the stream you can read the raw html and
either pass it to the WebBrowser control, or write it to a text file.
I also wrote an implementation of the WebClient class for .NET Compact
Framework in this product:-
http://inthehand.com/content/Networking.aspx

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top