How do I POST data to a remote URL in Classic ASP?

后端 未结 8 812
走了就别回头了
走了就别回头了 2020-12-08 08:06

I need to POST data to a url in the middle of a script.

  1. User fills out form:
  2. Form submits to process.asp: I need to PO
8条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 08:37

    You can do it by many way. With WebClient

     WebClient Client = new WebClient ();
     Client.DownloadFile("http://www.stackoverflow.com/myfile.html", "myfile.html");
    

    Or you can put the data in a stream to use it in your program:

    WebClient Client = new WebClient ();
    Stream strm = Client.OpenRead ("http://www.stackoverflow.com/myfile.htm");
    

    But I do prefer use HttpWebRequest:

    HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://www.stackoverflow.com/myfile.html");
    StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream());
    

    I prefer the second one because you can have more option for POST/GET or for Cookie.

提交回复
热议问题