This is the code that was created in Visual Studio 2013 by default. In the project properties, I decided to use Local IIS. WCF test test successfully tested. But if I access the page
http:
in the browser, then I see a blank browser screen, and Fiddler shows "HTTP / 1.1 400 Bad Request". I understand that I need to change web.config and the attributes for the method in the interface, but I don’t know how to do it. Could you help me? Thank.
IService1.cs
using System.Runtime.Serialization;
using System.ServiceModel;
namespace WcfService1
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetTime();
}
}
Service1.svc.cs
using System;
namespace WcfService1
{
public class Service1 : IService1
{
public string GetTime()
{
return DateTime.Now.ToShortTimeString();
}
}
}
web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
source
share