?
Solved

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

Posted on 2006-07-08
3
Medium Priority
?
968 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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
Suggested Courses

649 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