我试图设计一个图片上传功能到一个网站。 我使用ASP.NET 3.5,C#和WCF。类型'System.Web.HttpRequest'不能被序列化
我被要求完成下列操作:
1)请上传器的Web服务
2)返回进度更新到用户的文件上传。
3)在数据库中记录其他相关用户选择的选项。
IService.UploadPictures(HttpRequest request);
private UploadServiceClient upload;
protected void Page_Load(object sender, EventArgs e)
{
upload = new UploadServiceClient();
upload.UploadPictures(Request.Files);
}
当我编译,我得到以下错误:
所以,我通过与 以下服务合约创建一个WCF Web客户端开始了
Type 'System.Web.HttpRequest' cannot be serialized. Consider marking it with the DataContractAttribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
所以,我回到我的服务合同中,并且 将[OperationContract]更改为[DataContract] ,但是更改产生了相同的错误。
有人可以告诉我我做错了什么 并提供如何最好地向前迈进的例子吗?
谢谢你的时间。
感谢尼克(并道歉的延误)。 这是有道理的,并给了我一些工作。 我有一个相关的问题。我知道如何做到这一点,一旦上传到服务器的帖子,但是有可能做到这一点作为客户端的WCF回调?换句话说,当我从客户端调用方法(../upload.svc/uploadpictures/param)时,如何传递类型“List”的参数请求? 我的逻辑是我想使用JavaScript进行轮询(通过IFrame),并且通过单个JS方法处理所有事情似乎更容易。 再次感谢。 –
2009-10-19 21:26:08