Jede Art von Postback, Ajax oder Standard-MVC-Formularübergabe gibt Statuscode 301 zurück. Es scheint keinen Unterschied zu machen, was die Aktion oder der Controller ist. Das Ändern des Browsers von Chrome zu Firefox hat nicht geholfen.Postback gibt immer den Statuscode zurück 301 Permanent verschoben
<script>
$('.zzz').click(function (e)
{
e.preventDefault();
e.stopPropagation();
$.ajax({
url: '/XXX/yyy',
data: { test: "hello" },
type: "post",
success: function() { alert("success"); },
error: function() { alert("error"); }
});
});
</script>
Controller:
public class XXXController : AsyncController
{
[HttpPost]
public ActionResult YYY()
{
return null; // ====== NEVER REACHES HERE
}
}
Headers
Request URL:http://localhost:47038/xxx/yyy
Request Method:POST
Status Code:301 Moved Permanently
Remote Address:[::1]:47038
Referrer Policy:no-referrer-when-downgrade
Response Headers
=================
Access-Control-Allow-Origin:*
Content-Length:154
Content-Type:text/html; charset=UTF-8
Date:Tue, 21 Nov 2017 16:02:23 GMT
Location:http://localhost:47038/xxx/yyy/
Server:Microsoft-IIS/10.0
X-Frame-Options:SAMEORIGIN
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcdmF1bHRccHJpbnRlcnBpeG12Y3VpXFByaW50ZXJQaXhNdmNVSVxYWFhcWVlZ?=
Request Headers
================
view source
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-GB,en-US;q=0.9,en;q=0.8
Connection:keep-alive
Content-Length:10
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:ASP.NET_SessionId=rargvavdg0reeuhqvqkznsaj; MachineToken=a2fec363-6318-4ec3-8d2c-0eee116fc778; __RequestVerificationToken=80gj5joNWUpBjgjOsxkV0SkDwhrX3fNbzYTZrTaUGpJXlIEY7nyguehSDpz525JKyNfjlI5Two-poQs1dC2jw0kWnpvnK74iz4X3KV5MtSI1
Host:localhost:47038
Origin:http://localhost:47038
Referer:http://localhost:47038/xxx/Index/?product=puzzle
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Data
==========
test:hello
GET-Anfragen fein arbeiten, ist es nur Pfosten, die umgeleitet werden.
Warum wird 301 "Moved Permanently" zurückgegeben, anstatt dass die Aktionsmethode ausgeführt wird?
Überprüfen Sie Ihre Anfrage-Pipeline. Möglicherweise haben Sie einige Aktions-/Ergebnisfilter, die diese Antwort zurückgeben. – Shyju
Es gibt Code, um es in einem RequireSSL-Attribut zu tun, aber soweit ich sagen kann, wird das nie aufgerufen. – buffjape