我正在开发一个 MVC 项目,我试图通过 ajax 上传图像;这在 localhost 上绝对可以正常工作,但是它在 IIS Web 服务器上不起作用。一旦我按下提交按钮,它就会在控制台上显示错误,说:
我现在在这个问题上挣扎了 2 天,有什么建议吗?
NB
-> 我已经尝试过: url: '@Url.Action("FunctionName", "Controller")'
-> 应用程序池中的操作(其他在线帖子建议)
->我在使用 IIS 8 的 Godaddy 服务器上托管了这个站点。
->我使用 .NET 4.5.2 作为本地服务器
这是我的 jQuery:
$("#fileUserImage").change(function () {
userImage();
});
function userImage() {
var formData = new FormData();
var totalFiles = document.getElementById("fileUserImage").files.length;
for (var i = 0; i < totalFiles; i++) {
var file = document.getElementById("fileUserImage").files[i];
formData.append("fileUserImage", file);
}
$.ajax({
type: "POST",
url: '/UserRegistration/UserPhoto',
data: formData,
dataType: 'json',
contentType: …Run Code Online (Sandbox Code Playgroud)