How to post using http web request

any body can me how to post below form information using Http web request.


Sign in

Sign in name
Password (I forgot my password)
Next time automatically sign me in
Sign in »
Not a member yet? Click here to Join
.wrapper { width:25.5%; float:left; font-size:0.7em; margin-right:5.5%; text-align:left; } .wrapper p { width:0px; margin:0px; }
// // //
10/28/2008 10:21:05 AM 93655 articles. 6 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 4
Get it on Google Play
Get it on Apple App Store

10/28/2008 11:48:22 PM

Hi Singhrajankr,

You can use HttpWebRequest and HttpWebResponse as well as some other network I/O code  to implement it.

Please refer the following link.

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;

public class WebPageReader

    /// <summary>
    /// cookie
    /// </summary>
    private CookieCollection _Cookies = new CookieCollection();

    /// <summary>
    /// to keep the same session
    /// </summary>
    private CookieContainer cookieContainer = new CookieContainer();

    /// <summary>

    private bool isKeepAlive = false;

    public bool IsKeepAlive
        get { return isKeepAlive; }
        set { isKeepAlive = value; }


    public string GetHTML(string URL)
        return GetHTML(URL, "", System.Text.Encoding.ASCII);

    public string GetHTML(string URL, string PostData)
        return GetHTML(URL, PostData, System.Text.Encoding.ASCII);

    public string GetHTML(string URL, System.Text.Encoding encoding)
        return GetHTML(URL, "", encoding);

    /// <summary>
    /// </summary>
    /// <param name="URL"></param>
    /// <param name="PostData"></param>
    /// <param name="encoding"></param>
    /// <returns></returns>
    public string GetHTML(string URL, string PostData, System.Text.Encoding encoding)
        isKeepAlive = false;
        string _Html = "";

        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);
        request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/, application/msword, application/x-shockwave-flash, */*";

        if (_Cookies.Count > 0)
            request.CookieContainer.Add(new Uri(URL), _Cookies);
            request.CookieContainer = this.cookieContainer;

        //submit the data
        if (PostData != null && PostData.Length > 0)
            request.ContentType = "application/x-www-form-urlencoded";
            request.Method = "POST";

            byte[] b = encoding.GetBytes(PostData);
            request.ContentLength = b.Length;
            using (System.IO.Stream sw = request.GetRequestStream())
                    sw.Write(b, 0, b.Length);
                catch (Exception ex)
                    throw new Exception("Post Data Error!!", ex);
                    if (sw != null) { sw.Close(); }

        HttpWebResponse response = null;
        System.IO.StreamReader sr = null;


            response = (HttpWebResponse)request.GetResponse();

            _Cookies = response.Cookies;

            sr = new System.IO.StreamReader(response.GetResponseStream(), encoding);

            _Html = sr.ReadToEnd();

        catch (WebException webex)
            if (webex.Status == WebExceptionStatus.KeepAliveFailure)
                isKeepAlive = true;
                throw new Exception("DownLoad Data Error", webex);
        catch (System.Exception ex)
            throw new Exception("DownLoad Data Error", ex);
            if (sr != null) { sr.Close(); }
            if (response != null) { response.Close(); }
            response = null;
            request = null;

        return _Html;

Please check the following link.


Hua Jun Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
10/31/2008 4:11:40 AM

Similar Artilces:

web web web
Name: bahadir Email: Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

Could PB .NET Web Form POST security Information to others web page??
This is a multi-part message in MIME format. ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi,=20 Have anyone came across the requesion to POST security informations from = PB .NET web form web page to other web site?? I have tried many datys, Could any kind man give me some suggessions?? thanks & Best regards Leon ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML P...

hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

how to add theme for a web page when it's calling form windows application using Web Request class
Hi Everybody, I want to apply theme for a web page when it's calling from windows application using web Request class. Here is the code in windows applicationpublic static string GetPageHTML(string url) {string strHtml = String.Empty; try {Uri uri = new Uri(url); WebRequest resq = WebRequest.CreateDefault(uri);WebResponse resp = null;StreamReader sr; resq.Timeout = 99999999; resq.Credentials = CredentialCache.DefaultNetworkCredentials;resq.PreAuthenticate = false; resp = resq.GetResponse();sr = new StreamReader(resp.GetResponseStream()); strHtml = sr.ReadToEnd(); }catc...

can someone one give me difference between web form and mobile web form and which or where or when i'm using the forms?
thanks Marc Hi Marc, Based on my understanding, you want to know the differences between the ASP.NET web application and ASP.NET mobile web application. If I have misunderstood you, please feel free to let me know. The ASP.NET forms are used to develop the ASP.NET pages for desktop browsers and The ASP.NET mobile forms are used to develop the ASP.NET pages for mobile device browsers. When we create the ASP.NET mobile web forms pages, we can use nearly all the features of ASP.NET. But there are a couple of compatibility issues: Error Handling and Reporting. Tracing. Using Redi...

Use web.config with web forms?
 Hi All, I'm doing some unit testing of a web application, and would like to use settings from a web.config file.  Is this possible? Thanks much,- Mark I'd suggest keeping your Unit Tests in a seperate project and using it's own .config file. It will be a little repetition but it will help to keep things seperated for perf and reusability without bloating your production app. I agree with Curt. It is better to seperate options for testing and release version. This will decrease the job to be done once the unit testing process is finished.Haissam Abdul Mal...

Need Windows Form to Retrieve Information From Web Form
I have a cash and carry web site that customers can order products, the next day come in to the company to pay and pickup. I would like to create a windows application for the company to do two things: 1. download all the orders from the day before 2. upload price changes, product changes, category changes I've search the internet and forums and the only thing I can find that I think would actually link these two together would be a web service. Can you please tell me if I am heading in the right direction or if there is another method to link the two applications, if there are any pitf...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

Web Post... Request.form
Hi guys, I am working on a windows service which has to simulate as if the data posted is coming from a webpage. The remote page is a classic ASP page, which is reading the data as request.form.. Any suggestions ?? I am currently using httpwebrequest.. which seems to be not doing what I want to achieve. Thanks heaps..Sunny NAGIProper Preparation Prevents Poor PerformanceDont forget to click "Mark as Answer" on the post that helped you. Hi everyone, Never mind.. I solved my problem it was due to SSL Cheers!Sunny NAGIProper Preparation Prevents Poor Perform...

Web Part, Web Request, and HTML form Variables
I would like to build a web portal to display existing standalone web sites in separate web parts.  I was thinking I would need to use an IFRAME in a web part or have the web part do a web request and display the web response.  I would like to be able to monitor the http traffic between the web part and the existing web sites server so that I can perform additional processing on my server. Is there a way that I can capture (read only) the form variables/ hyperlink address when a user clicks a form submit button or hyper link in a web part that has an IFRAME? What if I used the w...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

Error When Debugging (Unable to start debugging on the web server. Unable to connect to the web server. Varify that the web server is running and that incoming HTTP request are not blocked by a firewa
Hi, When im going to run website its giving this error. Unable to start debugging on the web server. Unable to connect to the web server. Varify that the web server is running and that incoming HTTP request are not blocked by a firewall.  please help me to solve this problem. Thank you. Pubudu  If you are running your site off of a different machine than you are developing on, you need to install and configure the Visual Studio Remote Debugger on that machine. try to change the address from http://localhost to http://yourIP...   i hope it's worked...mak...

superreview requested: [Bug 410500] Add "Web form password" description to web form keychain items : [Attachment 295140] fix
Stuart Morgan <> has asked Mark Mentovai <> for superreview: Bug 410500: Add "Web form password" description to web form keychain items Attachment 295140: fix ...

Web resources about - How to post using http web request -

Wikipedia:Admin coaching/Requests for Coaching - Wikipedia, the free encyclopedia
Are added to the current request list in date order, newest at the end . Coaches will contact people at or near the top of the list, with preference ...

Quebec Rejects Ottawa's Request To Halt Right-To-Die Law
The federal government is preparing its own legislation on the issue. Quebec will forge ahead with the province's right-to-die law despite a ...

Feature Request: Automatically activate emergency features on making a 911 call
We reported recently on an Apple patent application for a ‘ panic mode ‘ on an iPhone, where using a specific finger on the Touch ID sensor could ...

Facebook Testing Undo Button for Sent Friend Requests?
Having second thoughts about that Facebook friend request you sent? The social network appears to be testing a way to pull it back. Reader Matteo ...

"When Palestinian artist Ashraf Fayadh was tried last year on blasphemy-related charges, the Saudi judges ...
"Instead, he was sentenced to 800 lashes and four years in prison over a book of poetry he wrote and for allegedly having illicit relations with ...

Google gets 2.2 million piracy takedown requests every day
The number of piracy takedown requests sent to Google is continuing to balloon: The search giant now receives around 2.2 million demands every ...

Belgian social media request for silence gets catty
As part of citywide safety measures, Belgian police issue a social media blackout request, and the public's response was fuzzy

Elon Musk Requests Applications For Autopilot Software Engineers On Twitter
Originally published on EV Obsession. Software engineers wanting to help in the creation of a fully autonomous driving system, listen up! Tesla ...

Reddit to honor 'Do Not Track' requests from visitors to its website
Reddit has decided to honor 'Do Not Track,' a feature that will ensure that it does not download third-party analytics on to browsers that enable ...

Kim Kardashian Requests a Very Pricey Push Present That Is Covered in Diamonds
Kim Kardashian Requests a Very Pricey Push Present That Is Covered in Diamonds

Resources last updated: 11/29/2015 10:01:06 PM