ASP.NET web service throw System.Net.WebException when upload file
<p>I have a a web service in asp.net which need to upload files to another server. The code run well when I play under Debug mode in Visual Studio. But when I host in IIS and call it, it throw System.Net.WebException. Here is my code:</p>

<pre><code>    [WebMethod]
    public string UploadFileToServer(string m_fileName, string m_username, string m_url)
    {
        string m_localFilePath = _currentDirectory + "\\" + m_username + "\\" + m_fileName;
        FileStream m_localFileStream = File.Open(m_localFilePath, FileMode.Open, FileAccess.Read);
        var reader = new BinaryReader(m_localFileStream);

        byte[] m_rawBytes = new byte[m_localFileStream.Length];
        reader.Read(m_rawBytes, 0, m_rawBytes.Length);
        try
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_url);
            request.Method = "POST";
            request.KeepAlive = false;

            Stream m_requestStream = request.GetRequestStream();
            m_requestStream.Write(m_rawBytes, 0, m_rawBytes.Length);
            m_requestStream.Close();
            m_localFileStream.Close();

            HttpWebResponse m_response = (HttpWebResponse)request.GetResponse();
            StreamReader m_reader = new StreamReader(m_response.GetResponseStream());

            string s = m_reader.ReadToEnd();

            return s;
        }
        catch (Exception ex)
        {
            return ex.ToString() + ex.Message;
        }
    }
</code></pre>

<p>It is very frustrated for me and it's not possible to turn it on my Visual Studio all the time.  Any suggestion or solutions? Thanks.</p>
