none
System.Net.WebException: The remote server returned an error: (404) Not Found.

    Question

  • Hi,

    I have an application that tries to get a response from a URL using the HttpWebRequest object. We got an error:

    System.Net.WebException: The remote server returned an error: (404) Not Found.

    We are able to telnet and ping to the server. We loaded the URL using our browser and worked fine.

    Any help is appreciated.

    thanks,

    Baldwin

     

     

    Friday, November 17, 2006 11:16 PM

Answers

  • Maybe you can show us the code and the URL?  If you can access it in a browser your code should have no problem finding it.  404 means it can't find the resource; which means the URL you're typing in the browser is probably different than the one in your code.
    Saturday, November 18, 2006 12:58 AM
    Moderator

All replies

  • Maybe you can show us the code and the URL?  If you can access it in a browser your code should have no problem finding it.  404 means it can't find the resource; which means the URL you're typing in the browser is probably different than the one in your code.
    Saturday, November 18, 2006 12:58 AM
    Moderator
  • Hi,

      I am also getting the same exception.

      When i tried to download a file using DownloadFile of System.Net.WebClient, it worked perfectely.

     When i tried to upload a file,  using UploadFile, I am getting the exception.

     

    My code is

     

    System.Net.WebClient client= new System.Net.WebClient();

    client.UploadFile("(websiteename)/", "c:/sample.txt");

     

    I am sure that the site address which I entered is existing.

     

    Then I tried the following code

     

     

    System.Net.WebClient client= new System.Net.WebClient();

    client.UploadFile("(websiteename)/test.txt", "c:/sample.txt");

     

     

    I created test.txt fileon server and tried to store sample.txt as test.txt on server.

    Then I got the following error

     

    System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.

     

    My intention is to upload a file to my server. I have the full path of the server, and ful path of the file to be uploaded. Please help me....

    Wednesday, July 25, 2007 7:20 AM
  • We are experiencing the similar issue.

    But when we use the IE, we get the 404 as well. We see the list, but when we select the file for upload we get the 404.

    Is it the IIS setup?

     

    Thanks,

    Mishko

    Thursday, September 20, 2007 2:49 PM
  • hello

    did you find any solution? why did you get 404 when making upload in iis7.0?

    andrew
    Wednesday, May 07, 2008 1:09 PM
  • That is u have to check with access rights?
    Mathi
    Thursday, September 25, 2008 8:50 AM
  • Hi,

    Have any of you solved this  issue  ?
    We have this issue at a client's place. When  we setup  and ran the s/w in our dev enviroment, everything  is fine.

    Our code interacts with  the server machine using web services.
    All webservice calls  from client  to server are  being received and served properly.

    the one problem  is downloading a file.
    Code is as follows
    ===
         WebClient wc = new WebClient();
         wc.DownloadFile(URIpath, pStrFileName);
    ===

    This gives the  following error

    04Mar2009 11:08:45  ERROR - Unable to download the input file from framework to Node  System.Net.WebException: The remote server returned an error: (404) Not Found.
       at System.Net.WebClient.DownloadFile(Uri address, String fileName)
       at ODSDataImport.DataImport.Main(String[] args)
    ==

    Any clues about  the error, potential solutions or where to look for ?

    thanks

    Anand
    Thursday, March 05, 2009 9:36 AM
  • Hi,

    Any solutions to this problem ? I have the same issue as Anand has.  Dev machine is running fine but it doesn't work well at a client.

    My code snippet:

      WebClient wc = new WebClient();
      wc.Credentials = CredentialCache.DefaultCredentials;

     try
     {
       wc.Downloadfile(dataSourceUrl, localSavePath);
     }
     Catch (WebException)
     {
        // Program falls into this section.
     }

    I cannot really reproduce the error scenario in my dev machine as I really don't know what's wrong at the client.

    Any help would be appreciated.

    Thanks,
    Thomas.

    Wednesday, October 14, 2009 1:53 AM
  • Hi , i am also having the same problem
    I am trying to download a file from a website and getting the following error
    "The remote server returned an error: (405) Method Not Allowed."

    I am using -- System.Net.WebClient

    Can anybody help me out please?
    Friday, December 04, 2009 8:18 AM
  • Hi, am also having the same problem...

    did anyone found a solution ?

    but all the other web serveries runs usually.

     

    System.Net.WebException: The remote server returned an error: (404) Not Found.

    Server stack trace: at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessResponseException(WebException webException, HttpWebResponse& response) at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream) at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)

    Monday, July 12, 2010 1:57 PM
  •         public void CreateUser(Resource r)
            {
                StringBuilder createXML = new StringBuilder();
                createXML.Append("<Resource xmlns=\"http://localhost/resource/extend\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">");
                createXML.Append("<ID>0</ID>");
                createXML.Append("<Alias>" + r.Alias + "</Alias>");
                createXML.Append("<FullName>" + r.FullName + "</FullName>");
                createXML.Append("<Country>" + r.Country + "</Country>");
                createXML.Append("<WorkLocation>" + r.WorkLocation + "</WorkLocation>");
                createXML.Append("<Department>" + r.Department + "</Department>");
                createXML.Append("<Title>" + r.Title + "</Title>");
                createXML.Append("<Level>" + r.Level.ToString() + "</Level>");
                createXML.Append("<ReportToAlias>" + r.ReportToAlias + "</ReportToAlias>");
                createXML.Append("<Serving>" + r.Serving.ToString() + "</Serving>");
                createXML.Append("<EmployedDate>" + r.EmployedDate.ToString() + "</EmployedDate>");
                if (r.LeftDate != null)
                {
                    createXML.Append("<LeftDate>" + r.LeftDate.ToString() + "</LeftDate>");
                }
                else
                {
                    createXML.Append("<LeftDate i:nil=\"true\" />");
                }
                createXML.Append("<LastUpdateDate>" + r.LastUpdateDate.ToString() + "</LastUpdateDate>");
                createXML.Append("</Resource>");
                string s = createXML.ToString();
                byte[] byteData = UTF8Encoding.UTF8.GetBytes(createXML.ToString());
    
    
                WebRequest request = WebRequest.Create(new Uri("http://localhost/api/resource", UriKind.Absolute));
                request.Method = "post";
                request.ContentLength = byteData.Length;
                request.UseDefaultCredentials = true;
           
                IAsyncResult ia = request.BeginGetRequestStream(new AsyncCallback(BeginCreateUserRequestStreamCallBack), new object[] { request, createXML.ToString() });
            }
    
            private void BeginCreateUserRequestStreamCallBack(IAsyncResult ia)
            {
                if (ia.IsCompleted)
                {
                    object[] parameters = ia.AsyncState as object[];
                    WebRequest request = (WebRequest)parameters[0];
                    Stream sw = request.EndGetRequestStream(ia);
                    Resource r = parameters[1] as Resource;
                    string postXML = parameters[1].ToString();
                    byte[] byteData = UTF8Encoding.UTF8.GetBytes(postXML); ;
                    sw.Write(byteData, 0, byteData.Length);
                    sw.Flush();
                    sw.Close();
                    IAsyncResult ir = request.BeginGetResponse(new AsyncCallback(BeginCreateUserRequestResponseCallBack), ia.AsyncState);
                }
            }
    
            private void BeginCreateUserRequestResponseCallBack(IAsyncResult ia)
            {
                if (ia.IsCompleted)
                {
                    object[] parameters = ia.AsyncState as object[];
                    WebRequest request = (WebRequest)parameters[0];
                    WebResponse repsone = request.EndGetResponse(ia);
                    StreamReader reader = new StreamReader(repsone.GetResponseStream());
                    string result = reader.ReadToEnd();
                    reader.Close();
                }
            }
    
    In
    BeginCreateUserRequestStreamCallBack
    
    and
      
    BeginCreateUserRequestResponseCallBack<br/>The request uri are same, and the uri can show in browser<br/><br/>but after<br/><br/> sw.Write(byteData, 0, byteData.Length);
                    sw.Flush();
                    sw.Close();<br/><br/>the new data didn't create.<br/><br/>when run to<br/>    WebResponse repsone = request.EndGetResponse(ia);<br/><br/>throw an system.net exception: the remote server return an error: nofind<br/><br/>Could you help me to resolve this issue?<br/>
    

    Dragon
    • Edited by 陈剑 Friday, September 09, 2011 9:35 AM
    Friday, September 09, 2011 9:34 AM