(a) Foreword
Currently, downloading files in Silverlight usually takes two ways to download files:
1, the client through the SaveFileDialog class for file downloads, server use byte array (byte[]) for data delivery.
2, the client through access to the service side of the general processing file (. ashx) to download the file.
For the 1th way to download, the main flaw is: Click to download, pop-up SaveFileDialog dialog box incredibly no filename!!! (You must have your own handwritten filename, and Silverlight has yet to be improved). The SaveFileDialog related properties and methods in Silverlight are as follows:
public sealed class
SaveFileDialog
{public
savefiledialog ();
public string Defaultext {get; set;}
public string Filter {get; set;}
public int FilterIndex {get; set;}
public string Safefilename {get;}
Public Stream OpenFile ();
public bool? ShowDialog ();
}
For the 2nd way to download, it is easy to expose the relevant information (processing file pages are sometimes directly in the address bar to display relevant information).
Silverlight mainly through HtmlPage.Window.Navigate (new Uri (URL)) to access general processing files, general processing file Download (response to execute);
So far, the development of Huawei Hummer Project has been more than half a year, mainly in the MVC and Silverlight development. Therefore, for the current project, I tried to invoke the MVC action in Silverlight to download, such as the following content will be around the topic to explain (at present, the wood has been updated to the project, only my Notebook design).
(ii) Related class diagrams and Filedownloadresult
In MVC, the action mainly takes the ActionResult as the return result, and then calls the ActionResult Executeresult () method to perform the related operation. However, the main actionresult for file operations so far are Filestreamresult, Filecontentresult, and Filepathresult, which are not easy to use (for file downloads). Therefore, I intend to use the Filedownloadresult class for file download related operations.