none
WCF ReST services not working in IIS 7.5

    Question

  • I know this has come up before, but I haven't seen an answer that fits this situation. I have a project in Visual Studio 2010 Ultimate RTM created with the "WCF REST Service Application" project template. It works fine in the Visual Studio development web server but I get 404.0 errors if I try to deploy it to IIS. I think IIS has all the correct .Net 4 stuff, but I'm not an IIS expert. I don't have a .svc file but I believe it shouldn't be necessary and, as I said, it works in the development server. Visual Studio and IIS are running on the same Windows Server 2008 R2 box.

    Thanks,

    Mark

    Tuesday, September 21, 2010 4:38 PM

Answers

  • Thanks for the answer, Ladislav. I checked everything you suggested and it was all already ok.

    I've got it working now. In principle, the solution was the same as I'd seen in other posts, but the detail is different because the other posts weren't dealing with IIS 7.

    In IIS Manager I selected my application in the tree view pane and went to Handler Mappings under Server Components in the Features View. I then double-clicked on svc-Integrated-4.0 and changed the Request path from *.svc to *. This had the effect of adding the following section under <system.webServer> in my web.config:

        <handlers>
          <remove name="svc-Integrated-4.0" />
          <add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
    
    
    • Marked as answer by Mark Itz Wednesday, September 22, 2010 9:45 AM
    Wednesday, September 22, 2010 9:44 AM

All replies

  • Hello,

    first check that your URL is correct. It should have from: http://localhost[:port]/ApplicationName/ServiceName

    Then check that your application is running in AppPool using .NET 4.0 in integrated mode. In IIS management go to your application hosting your REST services and in right panel choose Basic settings. It will show you name of Application Pool used. Than go back and in tree view on the left select Application Pools. In the list you can check the version of .NET Framework and mode of the pipeline the pool provides. You can also change AppPool settings her or go back to basic application settings and change app pool.

    Best regards,
    Ladislav

    Tuesday, September 21, 2010 8:01 PM
  • Thanks for the answer, Ladislav. I checked everything you suggested and it was all already ok.

    I've got it working now. In principle, the solution was the same as I'd seen in other posts, but the detail is different because the other posts weren't dealing with IIS 7.

    In IIS Manager I selected my application in the tree view pane and went to Handler Mappings under Server Components in the Features View. I then double-clicked on svc-Integrated-4.0 and changed the Request path from *.svc to *. This had the effect of adding the following section under <system.webServer> in my web.config:

        <handlers>
          <remove name="svc-Integrated-4.0" />
          <add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
    
    
    • Marked as answer by Mark Itz Wednesday, September 22, 2010 9:45 AM
    Wednesday, September 22, 2010 9:44 AM
  • I just had the same problem.  My fix was to use the instructions here:

    http://msdn.microsoft.com/en-us/library/ms751527.aspx

    specifically

    "%WINDIR%\Microsoft.Net\Framework\v4.0.30319\aspnet_regiis" –i –enable
    "%WINDIR%\Microsoft.Net\Framework\v4.0.30319\ServiceModelReg.exe" -r
    
    After that REST services worked fine.
    Thursday, January 06, 2011 12:32 PM
  • I have the same problem. Runs perfect in local dev but when in production I get 404 errors.  I tried all the answers given and still get 404 errors. Can someone please post what their entire system.serviceModel we.config section looks like.

    Thanks

     

    • Proposed as answer by NeoCed Monday, September 24, 2012 9:30 PM
    • Unproposed as answer by NeoCed Monday, September 24, 2012 9:31 PM
    Monday, March 21, 2011 5:14 PM
  • These are all the relevant bits from my config:

    	<system.web>
    		<compilation debug="true" targetFramework="4.0" />
    	</system.web>
    
    	<system.webServer>
    		<modules runAllManagedModulesForAllRequests="true">
    			<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    		</modules>
    		<handlers>
    			<!-- Make sure we can use this handler for any URL because we're using ReST. The default is
    			for it to be used only for .svc -->
    			<remove name="svc-Integrated-4.0" />
    			<add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
    		</handlers>
    	</system.webServer>
    
    	<system.serviceModel>
    		<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    		<standardEndpoints>
    			<webHttpEndpoint>
    				<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
    			</webHttpEndpoint>
    		</standardEndpoints>
    	</system.serviceModel>
    
    
    Wednesday, March 23, 2011 5:37 PM
  • I'm fighting what I think are similar issues, my site runs fine in VS2010 debugger but fails when I deploy to IIS.

    When I try the suggested add svc-Integrated-4.0 line above I get a 500.21 error,

    Handler "svc-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list.

    Oddly, even with the suggestion in place the site still works fine in debugger, just no luck deploying to IIS.

    Tuesday, March 29, 2011 4:03 AM
  • aspnet_regiis.exe -i -enable resolved my issue.

    Now the remove/add svc-Integrated-4.0 in config files resolves the 404.0 issue.

    • Proposed as answer by BryanCC Wednesday, August 17, 2011 12:06 AM
    Tuesday, March 29, 2011 8:01 PM
  • This was the ticket for me as well.  I added the lines to the config (and where does it say to do that?) even though my Handler Mappings didn't even show svc-integrated anything.  After getting that error, the aspnet_regiis.exe in visual studio command prompt solved the issue.

    Cheers!

    Wednesday, August 17, 2011 12:08 AM
  • I have done everything stated here with no success. I assume with .Net 4 you don't need to specify an endpoint in the web.config. True? I am just running this on IIS 7.5 on a regular Windows 7 Home operating system with Web add-ons. Is this the problem. I am not running Windows Server 2008? I created a simple TimeService which was available on another website as just a proof-of-concept. Again, as with everyone else, it works in debug, but not when deployed. I am using the Publish facility in VS 2010 to copy the changed code over to the inetroot/TimeService directory. What gets copied is the Global.ascx file and web.config file in the TimeService directory and copies the TimeService.dll and pdb file to the bin directory. I just can't seem to shake this 404 error. It shouldn't be this hard.

    Monday, September 12, 2011 7:17 PM
  • Just to check- you say you created a simple TimeService from another website...

    Did you use the WCF REST Service Application project template to create your service?  It creates it's own timeservice right out of the box.  I just used this one to troubleshoot the service.  There is no need for server 2008.

    I would create a new project using this template:

    http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd

    Then verify your Web.config has this section:

      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
          <add name="UrlRoutingModule"
               type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </modules>
    
        <handlers>
          <!-- Make sure we can use this handler for any URL because we're using ReST. The default is
    			for it to be used only for .svc -->
          <remove name="svc-Integrated-4.0" />
          <add name="svc-Integrated-4.0"
               path="*"
               verb="*"
               type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
               resourceType="Unspecified"
               requireAccess="Script"
               preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
      </system.webServer>
    

    You also mention it works in debug but not when deployed.  I take it you are running it in Cassini in debug?  I would also reconfigure your project to run in your local IIS before you deploy it.

    Hope that helps a bit!

    Thursday, September 15, 2011 4:07 PM
  • Thank you very much Philip ! now it worked for me too ;) [ i´m doing my dance of victory right now.. ]
    Wednesday, March 28, 2012 6:15 PM
  • Hey i am facing similar issue, i have hosted one rest wcf service on IIS7.5 and getting a response as "Request Error
    " which then leads to a 400 messag (Bad request). i also has hosted the older version of the same rest base wcf on the same IIS and its working fine in there. This latest version also works fine on my local dev box. but when i publish this to my QA/PROD box it start throwing this issue. dont know why i made so many change and end up getting the same result. Here is some of my config data.


        <services>
          <service name="Clearing.DataService.EntitiesDataService">
            <endpoint address="" binding="webHttpBinding" bindingConfiguration="higherMessageSize" contract="System.Data.Services.IRequestHandler" />
          </service>
          <service name="Clearing.DataService.ViewsDataService">
            <endpoint address="" binding="webHttpBinding" bindingConfiguration="higherMessageSize" contract="System.Data.Services.IRequestHandler" />
          </service>
        </services>
        <bindings>
          <webHttpBinding>
            <!-- configure the maxReceivedMessageSize value to suit the max size of the request ( in bytes ) you want the service to recieve-->
            <binding name="higherMessageSize" maxReceivedMessageSize="2147483647" />

          </webHttpBinding>
        </bindings>

    Friday, April 06, 2012 8:29 PM
  • I just had the same problem.  My fix was to use the instructions here:

    http://msdn.microsoft.com/en-us/library/ms751527.aspx

    specifically

    "%WINDIR%\Microsoft.Net\Framework\v4.0.30319\aspnet_regiis" –i –enable
    "%WINDIR%\Microsoft.Net\Framework\v4.0.30319\ServiceModelReg.exe" -r
    
    After that REST services worked fine.
    This solved my problem : many thanks !

    NeoCed

    Monday, September 24, 2012 9:32 PM