我正在尝试将文件从html5页面上传到WCF服务,但Files
中的HttpContext.Current.Request
对象为空。
任何想法?
我的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);
}
由于