Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Folks,

I need to consume a REST Web Service (using HTTPS ) in my ASP.NET Web application.
Have tried various examples from sites but no use. Please guide me if anybody knows the solutions.
When I am trying with some examples given from sites i am getting the below error


The underlying connection was closed: Could not establish trust relationship with remote server.

Please help me.


Thnaks in Advance
karthik
Posted
Updated 22-Jun-11 2:13am
v2

Hi Ruard,
Thanks for immediate repply, How i can use the code in your given article.
I could not understand how to make use of the above code before making a REST Web service request.
Please let me know more details.

Thnaks,
Karthik
 
Share this answer
 
Comments
[no name] 22-Jun-11 8:20am    
Add this line to your code before making a request:

System.Net.ServicePointManager.CertificatePolicy = new AcceptServerNameMismatch();
This is a problem with the certificate. By default the connection is not trusted and somehow the client cannot validate the certificate.

Take a look here why the connection may fail. And also a way on how to solve it:
http://weblogs.asp.net/tgraham/archive/2004/08/12/213469.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900