I'm facing a 404 error when making HTTPS POST requests to my WCF Service Application. Interestingly, HTTPS GET requests and metadata retrieval work fine. Here's a brief overview of my setup:
Web.config: Includes standard diagnostics, service behaviors enabling HTTPS, and basic HTTP bindings with Transport security mode. Global.asax.cs: Basic setup with CORS headers, and a special condition for HTTP OPTIONS method. Relevant Configurations:
Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="trace.log" />
</listeners>
</source>
</sources>
</system.diagnostics>
<appSettings>
<!--Settings-->>
</appSettings>
<connectionStrings />
<system.web>
<compilation debug="true" targetFramework="4.6.2" />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IserviceB">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="BasicHttpBinding_IserviceA">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://10.100.31.54:8043/serviceA.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IserviceA" contract="serivceA.IserviceA" name="BasicHttpBinding_IserviceA" />
<endpoint address="http://localhost:8081/serviceB.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IserviceB" contract="serviceB.IserviceB" name="BasicHttpBinding_IserviceB" />
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!--Assemblies-->
</assemblyBinding>
</runtime>
</configuration>
Global.asax.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Routing;
using System.ServiceModel.Activation;
using InvoiceWebService;
namespace InvoiceService
{
public class Global : System.Web.HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "*");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "*");
HttpContext.Current.Response.AddHeader("Access-Control-Expose-Headers", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.End();
}
}
}
}
I've ensured that my service metadata is accessible over HTTPS, and GET requests are successful. However, POST requests consistently return a 404 error. I've checked the endpoint configurations and tried various clientCredentialType settings without success.
What could be causing this 404 error on POST requests over HTTPS, and how can I resolve it?
Thank you for any insights or suggestions!