We have a ASP.NET application running and i have added a WCF Rest service to it. Locally and when deployed on test environments this works fine. The issue is when we deploy to our production environment, which is only HTTPS.
I have searched and read most of the answers online and have tried so many things. All with no luck.
Here is our simple code
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ReportingService
{
public ReportingService()
{
Thread.CurrentPrincipal = HttpContext.Current.User;
}
[OperationContract]
[WebGet(UriTemplate = "get/{id}", ResponseFormat = WebMessageFormat.Json)]
[PrincipalPermission(SecurityAction.Demand)]
public List<RawReportTable> GetReport(string id)
{
...
}
}
In Global.asax.cs we have
RouteTable.Routes.Add(new ServiceRoute("api/reporting", new WebServiceHostFactory(), typeof(ReportingService)));
In our web.config we have the following defined for system.serviceModel
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="api" helpEnabled="true" automaticFormatSelectionEnabled="true" maxBufferSize="500000" maxReceivedMessageSize="500000">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
<behaviors>
<endpointBehaviors>
<behavior name="api">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceCredentials>
<serviceCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" findValue="d5 85 5b 37 89 47 6f 89 71 5b b7 5d 87 6f 2e e5 24 aa 57 b6" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ReportingService">
<endpoint address="api/reporting" behaviorConfiguration="api" binding="webHttpBinding" bindingConfiguration="webBinding" contract="WayfinderFM.Service.api.ReportingService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
With this set up I get the following errors: Request Error: The server encountered an error processing the request. See server logs for more details.
I thought (and some example show) that I no longer need the services/endpoint stuff in the configuration as it is registered in the routing.
Removing that part we still get the same error. I have tried lots of different configurations, all with no luck.
The weird thing is /api/reporting/help actually shows. Just can't use any of the services.
Anybody have any idea? I'm hoping it is something simple I have missed.
Thanks all
Edit
I believe it is to do with the [PrincipalPermission(SecurityAction.Demand)] We use this to make sure the user is authenticated and we can access the token. I've found PrincipalPermission.Demand() failing once WCF Service was moved to SSL which sadly doesn't have an answer to it.