wcf - Type 'System.Web.HttpRequest' cannot be serialized -


I am trying to design a picture upload feature in a web site. I am using ASP.NET 3.5, C # and WCF.

I have been asked to complete the following:

1) Make the uploader a web service
2) The progress of the user as the upload of files Return updates.
3) Log in other relevant user-selected options in the database.

Therefore, I started by creating a WCF web client with the service contract below:

  IService.UploadPictures (HttpRequest request); Private Uploadservice client uploads; Protected Zero Page_load (Object Sender, EventAgds E) {upload = new UploadServiceClient (); Upload.UploadPictures (Request.Files); }  

When I compile, I get the following error:

Type 'System.Web.HttpRequest' can not be serialized. Consider marking it with DataContractAttribute, and marking all its members that you want them to be serialized with the DataMemberAttribute attribute.

So, I went back to my service contract and changed [Operation Contract] to [Data Contract]. But there was a single error in the change.

Can someone please tell me what I am doing and how to tell examples to move forward in the best way?

Thank you for your time.

You can not use an HttpRequest kind of something as WCF parameter error message says it all - HttpRequest is not serial, and to work with WCF, to sort types.

In addition to this, you have to remember: You only have one object instance here for the method that you are actually doing, being the WCF runtime, your request has been serialized (in the message To call, all the parameters have been passed by the method name) in the message (think: e-mail or XML file), server to send it, deserializing there and building a new copy of the given datatype (as in your DataContract The definition Copy), and doing something with it.

Your WCF service can be hosted well, eg. NT service or console is running in the app - in those circumstances there is no HTTPPrequency available!

You definitely have to recapture your solution - you need to check WCF streaming for uploading files to WCF - you will get 'many hits') or you'll get the HTTPEnd Object Without the use of the WCF service, you will have to find another way to pass relevant information (such as a list of file names).

Mark


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -