Posts

Showing posts with the label WebGet

Download file using WCF REST services

Hi, Generally we used to download a file using a handlers and sending parameters as a querystring (lets say download.ashx). Here few cases we might need to impersonate the user also. It purely depends on environment. Here is a sample code snippet just for reference. if (extension.Trim() == ".pdf") { context.Response.Clear(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", "attachment;filename=" + queryFile + ".pdf"); context.Response.BinaryWrite(System.IO.File.ReadAllBytes(file)); } But instead of that we can download a file as a stream using a WCF REST service too. Here is the code snippet for declaration in interface .. /// <summary> /// To fetch documents /// </summary> /// <param name="filePath">Represent text of filepath</param> /// <param name="fileName">Represents text of filename...