Der ASP.NET Core-Formular-POST führt zu einer HTTP 415 Unsupported Media Type-AntwortC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Der ASP.NET Core-Formular-POST führt zu einer HTTP 415 Unsupported Media Type-Antwort

Post by Anonymous »

Senden einer Formular-POST-HTTP-Anfrage (

Code: Select all

Content-Type: application/x-www-form-urlencoded
) an den unten stehenden Controller führt zu einer HTTP 415 Unsupported Media Type-Antwort.

Code: Select all

public class MyController : Controller
{
[HttpPost]
public async Task Submit([FromBody] MyModel model)
{
//...
}
}
Formular-Post-HTTP-Header:

Code: Select all

POST /submit HTTP/1.1
Host: example.com:1337
Connection: keep-alive
Content-Length: 219
Pragma: no-cache
Cache-Control: no-cache
Origin: https://example.com:1337
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: https://example.com:1337/submit
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8,nl;q=0.6
Dies funktionierte früher mit ASP.NET MVC 5 unter .NET 4.6.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post