0
votes

I created a restful web service in WCF. Everything works perfectly fine if i host it via IISExpress in Visual Studio. But after deploying it to local IIS, a 404.17 NOT FOUND error occures, when trying to access the .svc service. It states: "Not Found The requested content appears to be script and will not be served by the static file handler"

I already tried these solutions:

Launch Command Prompt - Start - cmd.exe cd C:\Windows\Microsoft.NET\Framework64[Dot Net Version] aspnet_regiis -ir and "C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation" and execute"servicemodelreg -i" to install them manually.

which did not change anything.

I'm pretty sure it's a configuration problem but can't figure it out since I'm quite unexperienced in doing this.

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  <appSettings/>
  <system.web>
    <compilation debug="true" targetFramework="4.6.2"/>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webHttpServiceBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service name="MyService.Service" behaviorConfiguration="ServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/"/>
          </baseAddresses>
        </host>
        <endpoint binding="webHttpBinding" contract="MyService.IMyService" behaviorConfiguration="webHttpServiceBehavior"/>
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost\myDB;initial catalog=DB;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>
</configuration>

I'm pretty frustrated after trying for days because developing this service was real fun until deployment failed completely. I would really appreciate any hints. Thanks!

1
Did you try the steps here codeproject.com/Tips/882774/… to remove ISAPI and CGI restrictions?Clay Ver Valen
"developing this service was real fun". It might be such a fun that you ignore the fact that WCF is almost dead and everyone else moves to ASP.NET Core Web API.Lex Li
@ClayVerValen Thanks, i will give it a try tonight.lionthefox
@LexLi Still works as supposed to (besides from my problem), so i don't really care too much. Also it's my first web service, so I'm not too fussed about it. Thanks for your advice though.lionthefox

1 Answers

0
votes

Solved it: The problem was that there was no IIS APPPOOL Login for my SQLSERVER Database configured. Here is the step by step explanation: https://stackoverflow.com/a/7698316/7547137