WCF 服务中的空 HttpContext.Current.Request.Files
我正在尝试将文件从 html5 页面上传到 WCF 服务,但 HttpContext.Current.Request
中的 Files
对象为空。
有什么想法吗?
我的 WCF 服务:
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class FileUploader
{
// test file uploader
[OperationContract]
[WebGet]
public string UploadFile()
{
string fileName = "no file selected";
HttpContext context = HttpContext.Current;
if (context != null)
{
if (context.Request.Files.Count > 0)
{
fileName = context.Request.Files[0].FileName;
}
}
return fileName;
}
}
调用的 javascript 是:
function UploadFile() {
FileUploader.UploadFile(HandleUploadResponse);
}
谢谢
I'm trying to upload files form a html5 page to a WCF Service but the Files
object in the HttpContext.Current.Request
is empty.
Any Idea?
my WCF Service:
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class FileUploader
{
// test file uploader
[OperationContract]
[WebGet]
public string UploadFile()
{
string fileName = "no file selected";
HttpContext context = HttpContext.Current;
if (context != null)
{
if (context.Request.Files.Count > 0)
{
fileName = context.Request.Files[0].FileName;
}
}
return fileName;
}
}
The calling javascript is:
function UploadFile() {
FileUploader.UploadFile(HandleUploadResponse);
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论