Deep Soni

Deep Soni

  • NA
  • 134
  • 22.2k

Set webconfig for HTTP & HTTPS request in WCF Restful Ser?

Jul 20 2018 12:01 AM

I have Azure Hosted WCF restful service. Now I have 2 URL one is with HTTP and HTTPS.

I use same project for both and in Azure, I need to publish on any of above URL and it automatic reflect to another.

Here is my webconfig. I was using HTTP but now I want to set both. In webconfig, I have set CustomBinding.

Here is my webconfig. Can anybody please suggest me what changes I need to add in following webconfig? So, it allows both HTTP and HTTPS.

I know how to set if my binding is WebHTTPBinding but I don't know how to set in CustomBinding. I have seen some links for both(HTTP and HTTPS) but all are of WebHTTPBinding.

Note: Following webconfig is working perfectly for HTTP.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
//Connectionstring
</connectionStrings>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
<add namespace="Microsoft.AspNet.Identity" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
</controls>
</pages>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.serviceModel>
<client />
<bindings>
<customBinding>
<binding name="myCustombinding">
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="s1" name="Project.MyProjectWebService">
<endpoint address="" binding="customBinding" bindingConfiguration="myCustombinding" contract="Project.MyProjectWebIService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="s1">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="customBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<directoryBrowse enabled="true" />
</system.webServer>
<runtime> //Assemblies </runtime>
</configuration>
 
 
 
 
 

Answers (1)