getting error 404 when using HttpWebRequest

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poojabawa
    New Member
    • Dec 2009
    • 7

    getting error 404 when using HttpWebRequest

    getting error 404 when using HttpWebRequest
  • poojabawa
    New Member
    • Dec 2009
    • 7

    #2
    i need help quicly...plz smbody help

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      404: means server could not find what you requested for. Care to post some code and explain further?

      Comment

      • Dheeraj Joshi
        Recognized Expert Top Contributor
        • Jul 2009
        • 1129

        #4
        Please make sure the requested resource(page) is in the proper document root...

        Regards
        Dheeraj Joshi

        PS: Please explain your queries bit clearly....

        Comment

        • poojabawa
          New Member
          • Dec 2009
          • 7

          #5
          i have to acess web page of icicilombard from my web application.
          and the url of that page is correct.......a s i am able to hit that page directly through the browser...but when i am sending request to that pafe i am getting error 404 on response.....


          code is as follows...

          HttpWebRequest myRequest = (HttpWebRequest )WebRequest.Cre ate(URL);
          myRequest.Metho d = "POST";
          myRequest.Timeo ut = 90000;
          HttpWebResponse myResponse = (HttpWebRespons e)myRequest.Get Response();

          Comment

          • poojabawa
            New Member
            • Dec 2009
            • 7

            #6
            new error 401 unauthorized encountered

            Comment

            • poojabawa
              New Member
              • Dec 2009
              • 7

              #7
              urgent help required

              Comment

              • poojabawa
                New Member
                • Dec 2009
                • 7

                #8
                have to acess web page of icicilombard from my web application.
                and the url of that page is correct.......a s i am able to hit that page directly through the browser...but when i am sending request to that pafe i am getting error 404 on response.....


                code is as follows...

                HttpWebRequest myRequest = (HttpWebRequest )WebRequest.Cre ate(URL);
                myRequest.Metho d = "POST";
                myRequest.Timeo ut = 90000;
                HttpWebResponse myResponse = (HttpWebRespons e)myRequest.Get Response();

                Comment

                • KrishnaSarala
                  New Member
                  • Dec 2009
                  • 4

                  #9
                  Make sure that any creditials is asking that site to you. If necessary provide.

                  Comment

                  • sanjib65
                    New Member
                    • Nov 2009
                    • 102

                    #10
                    I think the link below will solve your problem:

                    Comment

                    • semomaniz
                      Recognized Expert New Member
                      • Oct 2007
                      • 210

                      #11
                      I am not sure but you may have to add the following code
                      Code:
                      myRequest.Credentials = CredentialCache.DefaultCredentials;
                      
                      //or a vaild credentials to access the web page through an application

                      Comment

                      • poojabawa
                        New Member
                        • Dec 2009
                        • 7

                        #12
                        string MyUrl = ConfigurationSe ttings.AppSetti ngs["MyUrl"].ToString();
                        HttpWebRequest httpRequest = (HttpWebRequest )WebRequest.Cre ate(str);
                        httpRequest = (HttpWebRequest )WebRequest.Cre ate (str);
                        httpRequest.Pro xy = WebProxy.GetDef aultProxy();
                        httpRequest.Cre dentials = CredentialCache .DefaultCredent ials;
                        httpRequest.Use rAgent = "ccc";
                        WebProxy myProxy = new WebProxy("http://localhost:80",t rue);
                        // FindServiceSoap myFindService = new FindServiceSoap ();
                        // myFindService.P roxy = myProxy;
                        HttpWebResponse response = (HttpWebRespons e)httpRequest.G etResponse ();
                        Stream receiveStream = response.GetRes ponseStream ();
                        StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
                        string abc = readStream.Read ToEnd();

                        Above is the code i am using...
                        but am getting the same error

                        Comment

                        • chuckbrandt
                          New Member
                          • Dec 2009
                          • 1

                          #13
                          I think you need to close the response

                          I ran into the same situation and for me it turned out that I needed to do a resp.Close() on a previous HttpWebResponse , once I did that it worked for me. 404 is a red herring.

                          Chuck

                          Comment

                          • piyusht
                            New Member
                            • Jan 2010
                            • 8

                            #14
                            I had similar kind of problem using https. It requires some certificate from the source site. This piece of code worked for me. Hope it helps:

                            Code:
                            [B]//Subscribe this event in class where you use HTTPRequest[/B]
                            if (ServicePointManager.ServerCertificateValidationCallback == null)
                                            {
                                                ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(CustomXertificateValidation);
                                            }
                            
                             private static bool CustomXertificateValidation(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error)
                                    {
                                            return true;
                                    }

                            Comment

                            • jela75
                              New Member
                              • Mar 2010
                              • 1

                              #15
                              can some one please help. laptop will not connect to internet. all connections r fine, every time i try to open ie it tells me that http 404 could not b found. wat is this and how can i fix it

                              Comment

                              Working...