I am geting 403- forrebidden "The remote server returned an error: (403) Forbidden." while requesting Hosted Services.
My code for getting list is:
NameValueCollection RequestHeaders = new NameValueCollection();
X509Certificate cert = X509Certificate.CreateFromCertFile(CertificatePath);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUrl);
request.Method = "GET";
if (RequestHeaders != null)
resp = request.GetResponse();
The same code is working while I working in windows application.
Is there any settign that I need to set with IIS? I am working with IIS 7.5.
A similar issue is being reported in the following thread: http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/efb73b00-3610-4a21-ae16-80543451a4d0. It seems the user under which IIS is running does not have permission to read certificate data. Since you're reading the certificate from a .cer file, I would suggest you change the permissions on that file so that the user under which IIS is running has necessary permissions to read the data. One quick and dirty way to achieve this would be to grant "Everyone" full permission on that certificate file.
Hope this helps.