lundi 23 octobre 2017

asp.net mvc 5 - ajax upload , 500 (Internal Server Error)

I have problem with ajax post request, it will give 500 (Internal Server Error) , during development I do not have this problem but when I deploy on server this 500 (Internal Server Error) will be appear.

//////controller

[HttpPost] [ValidateAntiForgeryToken] public JsonResult RMAImageUpload(myModel model) { int imageId = 0;

        var file = model.ImageFile;

        if (file != null)
        {

            file.SaveAs(Server.MapPath("/path/" + file.FileName));

        }

        return Json(imageId, JsonRequestBehavior.AllowGet);

    }

///////View

var formData = new FormData(); formData.append('__RequestVerificationToken', $("[name='__RequestVerificationToken']").val()); formData.append('ImageFile', file[0]); formData.append('RMAId', $("[id='RMAId']").val());

    $.ajax({
        type: "Post",
        url: "@Url.Action("RMAImageUpload", "ImageStores")",
        data: formData,
        datatype: "json",
        processData: false,
        contentType: false,
        success: function(response) {
            ClearPreview();
            $("#uploadedImage")
                .append('<img src="/UploadedImage/' + response + '" class="img-responsive thumbnail"/>');
        }
    });

I do not know why this problem will appear when I deploy on server.

my Server ... shared windows host

Aucun commentaire:

Enregistrer un commentaire