Hi all,
im getting An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code
{"The remote server returned an error: (400) Bad Request."}
private string FileManagerServiceUrl
{
get
{
return "http://localhost/FileSync.SyncService/TransferService.svc";
}
}
this is my service url..
am calling this using..
string requestFile = @"D:\TestFolder\item.zip";
string fileSavePath = @"D:\TestFolder\copyContainer\testfile.zip";
DownLoadFileFromRemoteLocation(requestFile, fileSavePath);
and downloadfilefromRemoteLocation look like
private void DownLoadFileFromRemoteLocation(string downloadFileLocation, string downloadedFileSaveLocation)
{
string serviceUrl = string.Format("{0}/RetrieveFile/{1}", FileManagerServiceUrl, downloadFileLocation);
var request = WebRequest.Create(serviceUrl);
request.UseDefaultCredentials = true;
request.PreAuthenticate = true;
request.Credentials = CredentialCache.DefaultCredentials;
using (var response = request.GetResponse())
{
using (var fileStream = response.GetResponseStream())
{
CreateDirectoryForSaveLocation(downloadedFileSaveLocation);
SaveFile(downloadedFileSaveLocation, fileStream);
}
}
}
and RetrieveFile method like
public Stream RetrieveFile(string path)
{
if (WebOperationContext.Current == null) throw new Exception("WebOperationContext not set");
var fileName = Path.GetFileName(path);
WebOperationContext.Current.OutgoingResponse.ContentType = "application/octet-stream";
WebOperationContext.Current.OutgoingResponse.Headers.Add("content-disposition", "inline; filename=" + fileName);
return File.OpenRead(path);
}
im new to wcf and web... actually what is the issue issue.?
is any misconfiguration of web.config?