Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stumped by "The remote server returned an error: (403) Forbidden" with WCF Service in https

Tags:

c#

.net

asp.net

wcf

I have a WCF Service that I have boiled down to next to nothing because of this error. It is driving me up the wall. Here's what I have now.

A very simple WCF service with one method that returns a string with the value, "test".

A very simple Web app that uses the service and puts the value of the string into a label.

A web server running IIS 6 on Win 2003 with a SSL certificate.

Other WCF services on the same server that work.

I publish the WCF service to it's https location

I run the web app in debug mode in VS and it works perfectly.

I publish the web app to it's https location on the same server the WCF service resides under the same SSL certificate

I get, "The remote server returned an error: (403) Forbidden"

I have changed almost every setting in IIS as well as the WCF and Web apps to no avail. I have compared setting in the WCF services that work and everything is the same.

Below are the setting in the web.config for the WCF Service and the WEB app:

It appears the problem has to do with the Web app but I am out of ideas. Any ideas:

WCF Service:

  <system.serviceModel>
<bindings>

<client />

<services>
  <service behaviorConfiguration="Ucf.Smtp.Wcf.SmtpServiceBehavior" name="Ucf.Smtp.Wcf.SmtpService">
    <host>
      <baseAddresses>
        <add baseAddress="https://test.net.ucf.edu/webservices/Smtp/" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" contract="Ucf.Smtp.Wcf.ISmtpService" bindingConfiguration="SSLBinding">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="Ucf.Smtp.Wcf.SmtpServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" httpsHelpPageEnabled="True"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Web App:

    <system.serviceModel>
    <bindings><wsHttpBinding>
<binding name="WSHttpBinding_ISmtpService" closeTimeout="00:01:00"
 openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
 bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
 maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
 textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
 <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
 <reliableSession ordered="true" inactivityTimeout="00:10:00"
  enabled="false" />
 <security mode="Transport">
  <transport clientCredentialType="None" proxyCredentialType="None"
   realm="" />
  <message clientCredentialType="Windows" negotiateServiceCredential="true"
   establishSecurityContext="true" />
 </security>
</binding>

<client>


<endpoint address="https://net228.net.ucf.edu/webservices/smtp/SmtpService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISmtpService"
contract="SmtpService.ISmtpService" name="WSHttpBinding_ISmtpService">
<identity>
 <dns value="localhost" />
</identity>

  </client>
</system.serviceModel>
like image 572
RJ. Avatar asked Jun 02 '10 20:06

RJ.


People also ask

How do I fix the remote server returned an error 403 forbidden?

This problem usually happens when the computer is using the Proxy/VPN. Please disable the Proxy/VPN temporary and try again. If you're using the Proxy Settings in Driver Easy, please go to the Settings panel and set it to Use default browser settings.


2 Answers

I am going to answer my own question after spending hours and hours on this problem. I hope this helps all the other people who have beat their heads against the wall trying to figure this out. We finally got a network admin involved and solved this.

Here's the scenario and the solution:

We have a production server - everything works fine. We have a test server - we get a 403 forbidden error. Debugging locally works fine.

All the setting are identical or so we thought.

There is one setting that was wrong. In IIS in the properties of the virtual directory of the webservice under the Directory Security tab, the second Edit button is for IP restrictions. Our was set to deny access to all IP except for the list which should have included the IP for the test server. The IP of the test webserver was not granted rights. The reason it did not have rights was that it was recently cloned from the production virtual server and this setting was never adjusted to add the test virtual server.

like image 156
RJ. Avatar answered Sep 28 '22 23:09

RJ.


In my case, I had copied the source code from another machine and the virtual directory had not been created here. once i went to the project properties and created the virtual directory it worked fine.

like image 30
Salman Muhammad Avatar answered Sep 29 '22 00:09

Salman Muhammad