After reading different answers against the same thread i tried almost all the options mentioned in their discussions however i am still getting error:
Error No1: The remote server returned an error: (404) Not Found.
OR
Error No2:The remote server returned an error: (405) Method Not Allowed
.
Below is my code:
var httpWebRequest = (HttpWebRequest)WebRequest.Create("URL?Paramter1=pc&user=u1&password=p1");
httpWebRequest.ContentType = "application/json; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.Accept = "application/json";
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
I receive error on the last line i.e.
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
If i use httpWebRequest.Method="GET"
i receive the error number 1 as mentioned above and if i use httpWebRequest.Method="Post"
i receive the error number 2.
I too face this issue. Root cause of this error is may be mistook endpoint address in web config file..
This is my mistaken web config
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
It should be like this
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335/sample.svc" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
Now its working fine... Best is yours.. Good Luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With