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".

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.


Edit this Article
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?

Your Session is Ending
Login to Continue

© 2022 - ErnesTech - Privacy