I would suggest create one .aspx page or HTTPHandler then override ProcessRequest method.
public void ProcessRequest(HttpContext context)
{
//database table or PDF/word file
System.IO.MemoryStream mstream = GetData();
//Convert the memorystream to an array of bytes.
byte[] byteArray = mstream.ToArray();
string fileName= "test.pdf";
context.Response.Clear();
context.Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
context.Response.ContentType = "application/octet-stream";
context.Response.BinaryWrite(byteArray);
context.Response.Flush();
context.Response.End();
}
Your Silverlight application will act just like normal client and makes http Request using
<HyperlinkButton Content="Click Me" NavigateUri="Download.aspx?id=fileid" />
in above code
context.Response.AppendHeader("content-disposition", "attachment;
tells browser to prompt for OPEn/Save dialog.
I hope this will work.