Hi I need to post a request to aspx page within dos command line.. How can I do that ?
-
When you say post an http request, do you actually mean an HTTP POST, or do you just mean request a web page like any ol' browser would do (HTTP GET)? – Adam Plocher Feb 14 '17 at 16:03
8 Answers
telnet on port 80
For example:
telnet www.your-server.com/pageToTest.aspx 80
then type GET

- 30,382
- 27
- 123
- 206
-
I'm getting `C:\Windows\system32>telnet 'telnet' is not recognized as an internal or external command, operable program or batch file.` – CodyBugstein Mar 19 '14 at 13:09
-
1You can activte telenet package by typing these two command ,then after restart your computer and all will be fine !
pkgmgr /iu:TelnetClient
pkgmgr /iu:TelnetServer – N'Kauh Nathan-Régis Bodje May 11 '14 at 06:27 -
More information: http://www.esqsoft.com/examples/troubleshooting-http-using-telnet.htm – Ring Jan 16 '15 at 17:32
-
Telnet server is not needed (and is pretty much never recommended) in order to use the telnet command – Adam Plocher Feb 14 '17 at 15:59
All of these answers require installing a windows feature or other program. Powershell is installed by default and can be run from the command line
powershell -command "Invoke-WebRequest -Uri %url% -Method POST"

- 2,659
- 7
- 35
- 57
Create a .vbs file containing:
' Set your settings
strFileURL = "http://localhost/index.aspx"
strHDLocation = "stream.temp"
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
' Delete the temp file
objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
Then execute using:
cscript.exe scriptname.vbs

- 116
- 1
- 3
I've had some good luck with cURL http://curl.haxx.se/ to replicate sending JSON to a webservice. Perhaps this might help you too.

- 3,354
- 1
- 22
- 25
This works on Windows 10
powershell -command "Invoke-WebRequest -UseBasicParsing -Method POST -Uri http://example.com/login -Body username=exampleuser'&'password=test"
More info here https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.2

- 4,272
- 2
- 13
- 14
Telnet is really for connecting to a remote telnet server. In fact it (telnet server) is not present in Windows 10, only the client. You better use PowerShell. Here is an example accessing ODATA service: http://hodentekhelp.blogspot.com/2014/11/can-you-access-odata-with-powershell.html
Also review this thread: https://social.technet.microsoft.com/Forums/en-US/035062dd-5052-4abe-bd9a-8714f4184806/there-is-no-telnet-server-in-windows-10-what-is-the-purpose-of-telnet-client?forum=win10itprogeneral

- 21,988
- 13
- 81
- 109

- 443
- 2
- 5
- 15
Another way is to use wget which is a common command line tool (v useful for downloading). On windows you can get it from here http://gnuwin32.sourceforge.net/packages/wget.htm and its already part of most Linux distros. To use simply do the following;-
wget google.com
and that will return the following
--2018-03-20 16:31:39-- http://google.com/
Resolving google.com... 216.58.204.14
Connecting to google.com|216.58.204.14|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.google.co.uk/?gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg [following]
--2018-03-20 16:31:39-- http://www.google.co.uk/?gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg
Resolving www.google.co.uk... 216.58.201.3
Connecting to www.google.co.uk|216.58.201.3|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html@gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg'
[ <=> ] 12,441 --.-K/s in 0s
2018-03-20 16:31:40 (88.3 MB/s) - `index.html@gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg' saved [12441]

- 11
- 3