1. Take a Generic Handler file (.ashx) in web project. It’s automatically generated following method.
public void ProcessRequest(HttpContext context)
Context hold full url. So when we send a request to the handler this method automatically invoked. Now we can extract query string from url.
string action = context.Request.QueryString["action"].ToString();
Where action is the query string name.
2. From silverlight project prepare url and stream data (file) to send into the file server. OpenFileDialog is the class through which we can bind file data to Stream like.
3. Pass url and data stream by calling UploadFile(url, streamData). Below are the methods. This two methods duty are to send data of the respected url (our handler class).
In the handler class two types of operations take place. One is save data and one is retrieve data.
1. To save data, copy it inside ProcessRequest() method.
Path – is the location where the file is going to save. Here we saved path name in web.confg file. So we are just calling it.
Filename – is the name of file in which name it is going to save. We can pass the file name from silverlight project by binding query string like action. Below is the WriteFileToDisk() method.
2. To retrive data from ProcessRequest() method
Path - file location.
ReadMediaFile() method is below.