How to open IE with post info in C#?

后端 未结 6 1252
陌清茗
陌清茗 2020-12-03 12:32

I am developing a small program which as a windows form. On this form, I want to put a link, and when user click the link, a seperate IE browser will be open with post data.

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 12:59

    If you do a ShellExecute with a verb of OPEN on the url then the default web browser will be spawned and open the link. Alternatively, you can invoke Internet Explorer (once again using ShellExecute) with the url appended at the end of the string (so the string that you use for ShellExecute would look like this:

    System.Diagnostics.Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe", "http://google.com");
    

    You are talking about POST though, you cannot do a POST, the above line does a GET. Depending on how the website is set up you may be able to just append the parameters on the end of the url, like so:

    System.Diagnostics.Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe", "http://www.google.com/search?q=bing");
    

提交回复
热议问题