Home > Articles > Details

MVC Form Error "Incorrect Content-Type"


Question: Why is the MVC Form giving me an invalid content type from Request? the error says "Incorrect Content-Type".

Login to See the Rest of the Answer

Answer:
This error happens when you are trying to post data using a"Get" verb, sometimes this might slip by but sometimes you cannot do this.
In order to resolve this error, verify the following:

1. Make sure that form tags contains action="RightMethodOrFunctionInHere" and method="post"
2. If you are passing in the file make sure that the attribute "enctype" is set as enctype="application/{TheRightEncTypeInHere}". For example 
    see the code below:

<form action="MyController/ActionName" method="post" enctype="application/x-www-form-urlencoded">
//Your Form Controls come in here
</form>

Leave a comment below if this helped you.


If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Andrew said:

This is a nagging problem, why is this so hectic to resolve?

Posted On: December 05, 2021 15:49:27 PM

© 2022 - ErnesTech - Privacy