简体   繁体   中英

Handling web forms from application

I'd like to handle a simple web form from my application without showing the web site to the user. So, I should handle web form submit for credentials and then also handle another web form data and submission, as well as do some minor parsing from resulting pages. How should I tackle this problem, which control should be used? A nudge in proper direction will be most appreciated.

Traditional ASP.Net webforms are notoriously difficult to manipulate from code - especially when things like ViewState are required. In the case of one of these beasts, then your best bet is probably to setup a hidden WebBrowser control and to then use javascript commands to manipulate and submit the form (YUK!)

If, however, your form is a more clean ASP.Net MVC form with known parameter names, then you can probably quite easily make an appropriate HTTP GET or POST request using WebClient or HttpWebRequest from C#.

To work out what the web request needs to look like, try Fiddler2.

To understand HttpWebRequest in full .Net, see http://www.codeproject.com/Articles/18034/HttpWebRequest-Response-in-a-Nutshell-Part-1 - but you'll need to adjust this approach to use the async APIs on WP7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM