0

I've developed a WCF webservice and deployed it to my web server. Testing my mobile application, the web service returns HTTP 415 Error. Wrong Media Type. So, I went into IIS Server Manager and added .svc mime type. My app worked once. I made some changes to the app and redeployed it, and the 415 error returned.

Please Remember This: After you add mime type to your web service configuration, the Web.conf file is changed. IIS adds in the following:

 <system.webServer>
   <modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
    **<staticContent>
        <mimeMap fileExtension=".svc" mimeType="application/octet-stream" />
    </staticContent>**

Be sure to copy the StaticContent information back to your asp.net project web.config file. Otherwise, when you publish the app, it will overwrite the web.config file on IIS and your .json (and other site settings) will be gone. I finally remember this after 2 days of head-banging. Thanks, I hope this helps someone.

Adnan Umer
  • 3,669
  • 2
  • 18
  • 38
IrvineCAGuy
  • 211
  • 2
  • 12
  • Well, I got excited when I got a 500 error instead of 415. Adding mimeMap DID NOT fix this problem. Back to the head-banging. – IrvineCAGuy Mar 24 '16 at 04:27

1 Answers1

0

I erased my web service and re-wrote it. What I noticed is that Visual Studio does not put in the service endpoints to support JSON. Once I found that omission, I added:

 <behaviors> 
   <endpointBehaviors>
    <behavior name="jsonServiceBehaviour">
      <webHttp/>
    </behavior>
   </endpointBehaviors>

  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
   </serviceBehaviors>

And don't forget to add in....

<staticContent>
    <mimeMap fileExtension=".svc" mimeType="application/octet-stream" />
</staticContent>

I hope this helps someone.

IrvineCAGuy
  • 211
  • 2
  • 12