Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing Web App from WinForms client
Message
 
À
31/03/2005 14:12:09
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01000426
Message ID:
01000512
Vues:
20
Keith,

You can probably do what you need to without using the Web Browser control. For example, you can set Cookies etc. with the HttpWebRequest. I have a lengthy article that talks about advanced topics like Authentication, Cookies, Proxies etc. with wwHTTPWebRequest here:

http://www.west-wind.com/presentations/dotnetWebRequest/dotnetWebRequest.htm

However, if you need to run JavaScript on a form or you need to perform some other complex tasks you may have a hard time finding the right things to post to the server and automate the process.

Using an HTTP Proxy like Fiddler (www.fiddlertool.com) can help significantly with figuring out exactly what POST data and headers you need to send including Cookies.


Still in some situations you may still end up having to use a browser, in which case the Web Browser control will do. It's a built-in control so you don't need to install anything (it's part of Internet Explorer).


+++ Rick ---




>To all, thanks in advance for any ideas regarding this:
>
>Using HttpWebRequest and HttpWebResponse objects, I access a web application from a WinForms application. I log in to the web application, and receive an authentication key (in the form of a cookie). I use the key in all subsequent HttpWebRequests to submit a query and receive the response as a web page (a report). The report has links in it that take the user to other more detailed reports. The links on this page are relative paths, so I convert them to absolute paths and save the page as a temporary html file on the workstation, and launch a browser to open and display the html file using System.Diagnostics.Process.Start().
>
>Everything works fine up to this point. but I also want the user to be able click on links in this web page to navigate to details of the report. The user needs to pass his authentication KEY cookie back to the server to make any further requests of the web application. I tried inserting javascript in the temp html file to set a cookie (with document.cookie ="...") and it does seem to set the cookie because I can spit it back with a javascript alert(), but the server acts as if it isn't receiving the cookie and asks the user to log in. I also tried setting a cookie by putting a
<META HTTP-EQUIV="Set-Cookie" ... >
tag, with the same results. The browser just doesn't seem to be sending the cookie to the web server in the request when the user clicks on a link.
>
>My question: Is what I'm doing fundamentally impossible, perhaps because the browser is opening a file from disk rather than receiving an HTTP response?
>
>I'd be very grateful for any ideas
>
>Thanks,
>
>Keith Klein
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform