I copy without problem small file. When users try to upload a file of big dimension (I guess > 60MB) I got into a web Exception (404 Not Found).
I'm pretty sure that the problem is due to the file size. I got exception at
webRequest.GetResponse()
Do I need modification server side? Any suggestion is appreciate.
public static bool UploadFile(IResult result, string pathFile, Stream stream)
{
// upload effettivo del file su DB
HttpWebRequest webRequest = WebRequest.Create(ClientCommon.Properties.Settings.Default.FileServiceURI) as HttpWebRequest;
HttpWebResponse response = null;
Stream s = null;
try
{
webRequest.Method = WebRequestMethods.Http.Post;
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.KeepAlive = true;
using (WebRequestBuilder wrb = new WebRequestBuilder())
{
webRequest.ContentType = wrb.ContentType;
wrb.AddTextPart("cdFile", pathFile);
wrb.AddFilePart("file", stream);
wrb.AddTextPart("destination", pathFile);
if (wrb.GetContent(result, out s) == false)
return false;
s.CopyTo(webRequest.GetRequestStream());
}
response = webRequest.GetResponse() as HttpWebResponse;
return true;
}
catch (WebException exc)
{
result.SetError(exc.Message);
return false;
}
finally
{
if (response != null)
response.Close();
if (s != null)
// When the above code has ended, close the streams
s.Close();
}
}