$http.post() method is actally sending a GET

拥有回忆 提交于 2019-11-29 13:21:15
icza

This is due to a security consideration.

In your situation when a redirect is sent back from the server to the browser, the browser will not repeat the POST request (but rather just a "simple" GET request).

Generally speaking a browser will not send POST data to a redirect URL because the browser is not qualified to decide if you're willing to send the same data to the new URL what you intended to send to the original URL (think about passwords, credit card numbers and other sensitive data). But don't try to circumvent it, simply use registered path of your handler to POST to, or any of the other tips mentioned in the linked answer.

For context see question:

Go web server is automatically redirecting POST requests

You can read more on the subject here:

Why doesn't HTTP have POST redirect?

This code actually send GET to server

$http({
            method: 'POST',            
            params: {
                LoginForm_Login: userData.username,
                LoginForm_Password: userData.password
            },
            url: YOURURL
        }).then(

You need to use transformRequest, sample below actually send POST

$http({
            method: 'POST',
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
            transformRequest: function (obj) {
                var str = [];
                for (var p in obj)
                    str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                return str.join("&");
            },
            data: {
                LoginForm_Login: userData.username,
                LoginForm_Password: userData.password
            },
            url: YOURURL
        }).then(
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!