übergeben Ich versuche, Dateien und Parameter zu MVC-Controller-Aktion zu übergeben. Ich kann mein Modell, Dateien im Controller bekommen, aber kann nicht meine anderen Variablen in den Controllern wie string CommunId, string CommunContext
bekommen, ich weiß, es könnte wegen dieser false
Parameter sein, aber wenn ich es nicht auf false
setze, wird meine Controller-Aktion nicht einmal aufgerufen. Hier ist mein Code:Wie mit FormData Dateien und Parameter zu mvc Controller-Aktion
function submitNewCommunication(s, e) {
// var data = new FormData($(this).serialize()); //tried this one also
$.ajax({
url: '@Url.Action("CreateCommunication", "Communications")',
type: 'POST',
data: new FormData($('.createCommunicationForm').get(0)),
processData: false,
contentType: false,
success: function (result) {
alert('test');
}
});
}
My View
@using (Html.BeginForm("CreateCommunication", "Communications", new { CommunContext = ViewBag.CommContext, CommunId = ViewBag.CommId }, FormMethod.Post, new { @class = "createCommunicationForm"}))
{
//some code
}
Meine MVC-Controller:
public ActionResult CreateCommunication(string CommunId, string CommunContext, string[] PartyTypes, [ModelBinder(typeof(DevExpress.Web.Mvc.DevExpressEditorsBinder))]CommunicationModel item)
{
var files = Request.Files;
}
So Dateien und Modell sind hier, aber nicht diese anderen Variablen, vielleicht ist es eine einfache Lösung wie kann ich sie erhalten? Danke für jede Hilfe und Ihre Zeit.