getting error 404 when using HttpWebRequest
getting error 404 when using HttpWebRequest
Collapse
X
-
Please make sure the requested resource(page) is in the proper document root...
Regards
Dheeraj Joshi
PS: Please explain your queries bit clearly....Comment
-
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
-
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
-
-
I think the link below will solve your problem:
Comment
-
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 errorComment
-
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.
ChuckComment
-
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
Comment