无法通过网络将文件上传到主机 api
Cant Upload File To Host with web api
当我 运行 站点在本地系统文件上传工作正常
但在虚拟主机(plesk)
当我想上传文件到站点时
我收到这个错误
我该如何解决这个问题?
it is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level.
This error can be caused by a virtual directory not being
configured as an application in IIS
An application error occurred on the server. The current custom error
settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could,
however, be viewed by browsers running on the local server machine.
*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
我找到我的答案
WebApi Method name 引起的问题,
在我重命名之后,问题解决了;
(WebApi 中的命名约定)
当我 运行 站点在本地系统文件上传工作正常 但在虚拟主机(plesk) 当我想上传文件到站点时 我收到这个错误 我该如何解决这个问题?
it is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
*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
我找到我的答案 WebApi Method name 引起的问题, 在我重命名之后,问题解决了; (WebApi 中的命名约定)