当我在本地系统运行站点文件上传时,工作正常,但是在虚拟主机(plesk) 中,当我想上传文件到站点时,我得到了这个错误,,我怎么能修复这个问题呢?
在应用程序级别之外使用已注册为allowDefinition='MachineToApplication‘的部分是错误的。导致此错误的原因可能是IIS中未将虚拟目录配置为应用程序。 服务器上发生应用程序错误。此应用程序的当前自定义错误设置防止远程查看应用程序错误的详细信息(出于安全原因)。但是,运行在本地服务器机器上的浏览器可以查看它。
*api上传方法**
[HttpPost]
[ActionName("Files")]
public JsonResult Files_Post([IoCModelBinder(typeof(NullableEntityModelBinder))] MediaCategory mediaCategory)
{
try
{
var list = new List<ViewDataUploadFilesResult>();
foreach (string files in Request.Files)
{
HttpPostedFileBase file = Request.Files[files];
if (_fileService.IsValidFileType(file.FileName))
{
ViewDataUploadFilesResult dbFile = _fileService.AddFile(file.InputStream, file.FileName,
file.ContentType, file.ContentLength,
mediaCategory);
list.Add(dbFile);
}
}
return Json(list.ToArray(), "text/html", Encoding.UTF8);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
}在控制台中:
File
accepted
:
true
height
:
473
lastModified
:
1478297024176
lastModifiedDate
:
Sat Nov 05 2016 01:33:44 GMT+0330 (Iran Standard Time)
name
:
"nvs5.jpg"
previewElement
:
div.dz-preview.dz-processing.dz-image-preview.dz-error.dz-complete
previewTemplate
:
div.dz-preview.dz-processing.dz-image-preview.dz-error.dz-complete
processing
:
true
size
:
100824
status
:
"error"
type
:
"image/jpeg"
upload
:
Object
bytesSent
:
101006
progress
:
100
total
:
101006
__proto__
:
Object
webkitRelativePath
:
""
width
:
840
xhr
:
XMLHttpRequest
__proto__
:
File发布于 2017-05-13 09:21:57
我发现我的答案问题是由WebApi方法名引起的,在我将该问题重新命名之后;( WebApi中的名称约定)
https://stackoverflow.com/questions/43914965
复制相似问题