I am deploying my site locally to the IIS on my Windows 7 machine, which has been working for a month now. All the necessary features are installed, ASP.NET is activated and so on. I also activated the WCF features.
Now I am trying to host a WCF service. While running it in Visual Studio, it works perfectly (except for some other problems I already asked about on SO). However, on my IIS it gives the following IIS error:
HTTP-fejl 500.19 - Internal Server Error.
: The requested page cannot be accessed because the related configuration data for the page is invalid. Error Code: 0x80070005 Notification: BeginRequest Module: IIS Web Core Requested URL: ... Physical Path: ... Logon User: Not yet determined Logon Method: Not yet determined Handler: Not yet determined Config Error: Cannot read configuration file Config File: ... Config Source:
Now, this is my web.config:
<system.webServer>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="ForumOperationService">
<endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior"
binding="webHttpBinding" contract="IForumOperationService" />
</service>
</services>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory" validate="false"/>
<add name="AjaxToolkit" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
And this is my WCF webservice test:
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ForumOperationService : IForumOperationService
{
public string Horse(string prefixText, int count)
{
return "hestWCF";
}
public List<SystemTagDTO> GetTags(string prefixText, int count)
{
var dfasd = new List<SystemTagDTO>();
dfasd.Add(new SystemTagDTO() { Isvisible = true, Value = "Aktant" });
dfasd.Add(new SystemTagDTO() { Isvisible = true, Value = "Beretter" });
return dfasd;
}
}
I can see that the error is removed when I remove the behaviours/services + handler entry.
Now, my question is: Why does it work in VS 2012, and not on my local IIS? Should I somehow set the WCF service to be hosted on the IIS directly? And if so, how?
I can see there is a mistake in your configuration file. WCF related config elements like behaviors, serviceHostingEnvironment & services should be with in <system.ServiceModel>
tag and not within <system.webServer>
. Try fixing that and see if it works for you.