Wie lese ich RAW JSON -Anforderungskörper in ASP.NET MVC bei Verwendung von Application/JSON?Jquery

JQuery-Programmierung
Anonymous
 Wie lese ich RAW JSON -Anforderungskörper in ASP.NET MVC bei Verwendung von Application/JSON?

Post by Anonymous »

beim Senden von Daten über AJAX mithilfe von ContentType: application/JSON sind die Daten in Request nicht verfügbar. FORMENE In meinem ASP.NET-MVC-Controller. Request.form ["input1"].

Code: Select all

    // reading form data
var form = $("form")[0];
var formData = new FormData(form);

var object = {};
formData.forEach(function(value, key){
object[key] = value;
});
var data = JSON.stringify(object);

// ajax part
// POST application/json; charset=utf-8
$.ajax({
type: "POST",
url: "@Url.Action("FormSubmit","Home")",
data: data,
dataType: "json",
async: true,
contentType: "application/json",
processData: true,
success: function(result) { },
error: function(result) { }
});
Controller -Teil

Code: Select all

    [HttpPost]
public ActionResult FormSubmit(string input1, string input2)
{
var httpContext= HttpContext;
var response = Response;
var request = Request;
throw new NotImplementedException();
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post