Results 1 to 7 of 7

Thread: [RESOLVED] POST string to webapge

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Resolved [RESOLVED] POST string to webapge

    Hey guys I have been trying to find a solution for this and I haven't run across anything helpfull so hopefully you can help me here.

    This is a windows app not an ASP web app, if that matters.

    I am trying to use something like this to POST a string to a webpage on my server. Is this possible from a windows app? I have no idea how to go about it and can't seem to find anything that is helping.

    Code:
     string sql = "INSERT INTO tblWhatever (field1,field2) VALUES ('1','2')";
                HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("");
                myReq.Method = "POST";
                myReq.ContentType = "application/x-www-form-urlencoded";
                StreamWriter writer = new StreamWriter(myReq.GetRequestStream());
                writer.Write(sql);
                writer.Close();
    Alternatively, I have one function that checks to see if an account ID is valid. I would like to send the AccountID to a webapge on my server, have the webpage see if the account is valid then send back a response of "yes or no" to my windows app. Is that possible?

    Thanks for any input you can give me!
    Last edited by Arc; Mar 14th, 2008 at 06:12 PM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: POST string to webapge

    Why not use a web-service instead. it's type safe and more reliable than this method
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Re: POST string to webapge

    A web service? I am not even sure what that is. Would that have to be a completely different program or can I integrate it into this Windows app?
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: POST string to webapge

    Quote Originally Posted by Arc
    A web service? I am not even sure what that is. Would that have to be a completely different program or can I integrate it into this Windows app?
    The web service is like a web accessed class library. it can contain methods to be called (executed) remotely and return values. You can google a better definition.
    You can include it in your website and reference it from the Windows App
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Re: POST string to webapge

    My website is made with PHP not asp.net...hrmm
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: POST string to webapge

    This search for 'Arc' works with VBForums (which is a php site

    Code:
    static void Main(string[] args)
            {
    
                string values =
                   "do=process&showposts=0&quicksearch=1&s=&query=Arc";
    
    
                HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.vbforums.com/search.php");
                myReq.Method = "POST";
                myReq.ContentType = "application/x-www-form-urlencoded";
    
                StreamWriter writer = new StreamWriter(myReq.GetRequestStream());
                writer.Write(values);
                writer.Close();
    
                HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
                Stream stream = myResp.GetResponseStream();
                StreamReader reader = new StreamReader(stream);
                string response = reader.ReadToEnd();
    
                Console.WriteLine(response);
                Console.ReadLine();
    
                            
            }

  7. #7

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Re: POST string to webapge

    That seems to be working perfectly. Thanks so much for the help!
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width