Beware of "Friendly URLs"!
@Aravamudan's response was the solution to my problem. My website (via my web.config
file) was using "Friendly URLs" (via the IIS URL Rewrite 2.0 module
). I had previously designed my "Friendly URLs" to remove file extensions from webpage URLs (eg, "foobar.aspx" showed up as "foobar" on the browser's address line). However, these "Friendly URLs" were also converting my "POST
" requests into "GET
" requests. These HTTP Method
conversions were nullifying my HTML-POST-to-ASPX functionality.
So, the simple solution was for me to just exclude the ".aspx
" file extension from my HTTP POST
requests.
Longstoryshort, to add a nuanced solution to the question... you can POST data from an HTML form to an ASPX page with the following adjustment:
<form action="/foobar.aspx">
<form action="/foobar">
Moreover, you can POST data from AJAX to an ASPX page with the following adjustment:
ajaxObj.open("POST", /foobar.aspx, true)
ajaxObj.open("POST", /foobar, true)
I hope that helps you.
footnote: I would've written this 'answer' as a comment under @Aravamudan's answer, but I don't have enough reputation points (43 out of 50). So, I just upvoted his (which, unfortunately, was at a -1); and fleshed out these additional details.