?
Solved

C# windows application needs to send a string as a parameter to a webpage

Posted on 2006-07-08
3
Medium Priority
?
965 Views
Last Modified: 2013-12-16
I have a C# windows app that needs to do something like what I have in Javascript here:

$data_string = escape($data_string);            
submitdatawindow = window.open("http://www.somewebpage/submithere.php?data_string=" + $data_string);
submitdatawindow.close();

Basically I need to send a string like an HTML POST (with the escape function) to a web page.

Even better if someone can show me how to POST to a webpage from a C# windows application without actually having to open an IE browser.

Thanks, all
0
Comment
Question by:RichardRiga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Author Comment

by:RichardRiga
ID: 17066665
I was looking this up on the web and had a thought... can I open an instance of IE using System.Diagnostics.Process.Start then, when I am finished with it, System.Diagnostics.Process.Kill it?
0
 
LVL 6

Accepted Solution

by:
MuhammadAdil earned 1000 total points
ID: 17067222
0
 
LVL 11

Assisted Solution

by:anyoneis
anyoneis earned 1000 total points
ID: 17067279
Here is a windows forms app that does this:

[Code]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;    

namespace SendToWebSite
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public DataSet m_DataSet = new DataSet();

        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder rText = new StringBuilder();

            rText.Append(baseUrlTextBox.Text + '?');
            foreach (DataRow dr in m_DataSet.Tables[0].Rows)
            {
                rText.Append(System.Web.HttpUtility.UrlEncode(dr["Param"].ToString()) + '=');
                rText.Append(System.Web.HttpUtility.UrlEncode(dr["Value"].ToString()) + '&');
            }
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(rText.ToString());
           
            HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
            StreamReader respReader = new StreamReader(resp.GetResponseStream());
            responseTextBox.Text = respReader.ReadToEnd();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Param", typeof(string));
            dt.Columns.Add("Value", typeof(string));
            m_DataSet.Tables.Add(dt);

            dt.Rows.Add("id", "343");

            parametersDataGridView.DataSource = m_DataSet;
            parametersDataGridView.DataMember = dt.TableName;
        }
    }
}
[/Code]
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question