none
Hosting WCF service on IIS/XP - browsing to the .SVC gives a plain text view of the contents

    Question

  • I am trying to use some of the WCF samples (specifically the one called "IIS Hosting Using Inline Code", but I don't think the problem is specific to that sample).  I am on XP SP2 (so IIS 5.1), with VS 2005 and .NET 3.0 installed.

     

    I build the sample, which deploys a .SVC file and a .DLL to a virtual directory in IIS and try to browse the service.   I am expecting to see the usual 'metadata' page telling me what the service is called and what operations a client could use.

     

    Instead I see a plain text page showing the raw contents of the .SVC file.   Evidently the ASPNET_ISAPI.DLL is not correctly mapped for .svc urls.

     

    I have tried the following, based on several other posts in this forum, but they have not worked for me:

     

    1. Run %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe /i /enable

    2. Run

    "%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" /r /x /v /y > ServicemodelregOut.txt

    3. used the IIS Manager to add an application mapping for '.SVC' extensions to use the .NET 2.0  version of aspnet_isapi.dll.   (I worked around the bug where the path in that little  dialog shows '...' until you click on it.)

     

    The output file from ServiceModelReg.exe shows the following:

     

    Microsoft(R) Windows Communication Foundation Installation Utility
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
    Copyright (c) Microsoft Corporation.  All rights reserved.


    The ServiceModelReg tool will take the following actions:
    Reinstalling configuration section system.serviceModel to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.
    Reinstalling configuration section system.runtime.serialization to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.
    Reinstalling configuration section system.serviceModel.activation to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.
    Adding configuration entry for BuildProvider:
     System.ServiceModel.Activation.ServiceBuildProvider, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Reinstalling compilation assembly node to System.Web section group:
     System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
    Reinstalling compilation assembly node to System.Web section group:
     System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
    Reinstalling compilation assembly node to System.Web section group:
     System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Reinstalling HttpHandlers node to System.Web section group:
     *.svc
    Reinstalling HttpModules node to System.Web section group:
     ServiceModel
    Removing the Protocol node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     net.tcp
    Removing the TransportConfiguration node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     net.tcp
    Removing the Protocol node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     net.pipe
    Removing the TransportConfiguration node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     net.pipe
    Removing the Protocol node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     net.msmq
    Removing the TransportConfiguration node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     net.msmq
    Removing the Protocol node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     msmq.formatname
    Removing the TransportConfiguration node from the system.web section in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config for protocol:
     msmq.formatname
    Reinstalling Web Host Script Mapping for extension: .svc
    Reinstalling WMI classes.
    Reinstalling Windows CardSpace (idsvc).
    Reinstalling Net.Tcp Port Sharing Service (NetTcpPortSharing).
    Reinstalling HTTP namespace reservations.


    Uninstalling: Machine.config Section Groups and Handlers

    Installing: Machine.config Section Groups and Handlers

    Uninstalling: System.Web Build Provider

    Installing: System.Web Build Provider

    Uninstalling: System.Web Compilation Assemblies

    Installing: System.Web Compilation Assemblies

    Uninstalling: HTTP Handlers

    Installing: HTTP Handlers

    Uninstalling: HTTP Modules

    Installing: HTTP Modules

    Uninstalling: Protocol node for protocol net.tcp

    A Protocol node does not exists in the system.web section for protocol net.tcp in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: TransportConfiguration node for protocol net.tcp

    A TransportConfiguration node does not exists in the system.web section for protocol net.tcp in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: Protocol node for protocol net.pipe

    A Protocol node does not exists in the system.web section for protocol net.pipe in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: TransportConfiguration node for protocol net.pipe

    A TransportConfiguration node does not exists in the system.web section for protocol net.pipe in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: Protocol node for protocol net.msmq

    A Protocol node does not exists in the system.web section for protocol net.msmq in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: TransportConfiguration node for protocol net.msmq

    A TransportConfiguration node does not exists in the system.web section for protocol net.msmq in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: Protocol node for protocol msmq.formatname

    A Protocol node does not exists in the system.web section for protocol msmq.formatname in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: TransportConfiguration node for protocol msmq.formatname

    A TransportConfiguration node does not exists in the system.web section for protocol msmq.formatname in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\web.config.

    Uninstalling: Web Host Script Mappings

     Removing script mapping from location IIS://localhost/W3SVC.

     Removing script mapping from location IIS://localhost/W3SVC/1/ROOT/Printers.

    Installing: Web Host Script Mappings

     Adding script mapping to location IIS://localhost/W3SVC.

    Repairing: WMI Classes

    Repairing: Windows CardSpace (idsvc)

    Repairing: Net.Tcp Port Sharing Service (NetTcpPortSharing)

    Uninstalling: HTTP Namespace Reservations

    Installing: HTTP Namespace Reservations

    The ServiceModelReg tool has completed successfully.

     

    I dropped a test.aspx file into the same virtual directory; the browser renders it correctly. 

     

    I dropped a test.svc file into the same virtual directory; the browser renders this as a plain text view of the raw file contents.

     

    What else can I try?

    Friday, October 12, 2007 3:36 PM

Answers

All replies

  •  

    Hello,

     

    It sounds like you might not have ASP.NET 2.0 installed on the computer where you're trying to host the WCF service.  When you load a simple asp.net page, do you see its contents or does the page load as you expect?

     

    If the page does not load as you expect, you will want to install ASP.NET 2.0 on the system by doing the following:

    1. cd to %windir%\Microsoft.NET\Framework\v2.0.50727
    2. run aspnet_regiis -i -enable

    ASP.NET 2.0 should now be installed.  The next step is to reinstall WCF so it hooks into the ASP.NET and HTTP pipelines:

     

    1. cd to %windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
    2. run ServiceModelReg.exe -i -x

    The -i switch tells ServiceModelReg.exe to install WCF.  (The -r command you were running before was to reinstall WCF; it sounds like WCF may not have been properly installed previously.)

     

    The -x switch tells ServiceModelReg.exe to include the necessary custom action scripts.

     

    You can add the -y and -v switches if you'd prefer to supress confirmation (-y) or see verbose output (-v).

     

    Your system could have gotten into this state if you installed IIS on the system AFTER WCF was installed.  It could also happen if you had IIS on the system, but never enabled ASP.NET before installing WCF.

     

    Hope this helps!

    Richie Weldon

    SDET, WCF

    Friday, October 12, 2007 11:35 PM
  • Richie,

     

    Thanks.  I ran the steps you suggested, but I still have the same symptoms (.svc URL renders as raw text in browser).

     

    A simple test.aspx page (containing a few HTML tags) renders as expected.

     

    A simple test.svc page just renders as raw text.

     

    The output file from this run of ServiceModelReg -i -x -v -y contains this:

     

    Microsoft(R) Windows Communication Foundation Installation Utility
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
    Copyright (c) Microsoft Corporation.  All rights reserved.


    The ServiceModelReg tool will take the following actions:
    Adding configuration section system.serviceModel to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.
    Adding configuration section system.runtime.serialization to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.
    Adding configuration section system.serviceModel.activation to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.
    Adding configuration entry for BuildProvider:
     System.ServiceModel.Activation.ServiceBuildProvider, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Adding new compilation assembly node to System.Web section group:
     System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
    Adding new compilation assembly node to System.Web section group:
     System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
    Adding new compilation assembly node to System.Web section group:
     System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Adding HttpHandlers node to System.Web section group:
     *.svc
    Adding HttpModules node to System.Web section group:
     ServiceModel
    Updating Web Host Script Mapping for extension: .svc
    Adding WMI classes.
    Adding Windows CardSpace (idsvc).
    Adding Net.Tcp Port Sharing Service (NetTcpPortSharing).
    Adding HTTP namespace reservations.


    Installing: Machine.config Section Groups and Handlers

    Configuration section system.serviceModel already exists in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.

    Configuration section system.runtime.serialization already exists in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.

    Configuration section system.serviceModel.activation already exists in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config.

    Installing: System.Web Build Provider

    A configuration entry already exists for BuildProvider System.ServiceModel.Activation.ServiceBuildProvider, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.

    Installing: System.Web Compilation Assemblies

    All compilation assembly nodes already exist in System.Web section group.

    Installing: HTTP Handlers

    HttpHandlers node *.svc already exists in System.Web section group.

    Installing: HTTP Modules

    HttpModules node ServiceModel already exists in System.Web section group.

    Installing: Web Host Script Mappings

    A Web Host Script Mapping already exists for extension .svc.

    Installing: WMI Classes

    WMI classes are already installed.

    Installing: Windows CardSpace (idsvc)

    Windows CardSpace (idsvc) is already installed.

    Installing: Net.Tcp Port Sharing Service (NetTcpPortSharing)

    Net.Tcp Port Sharing Service (NetTcpPortSharing) is already installed.

    Installing: HTTP Namespace Reservations

    HTTP namespace reservations are already installed.

    The ServiceModelReg tool has completed successfully.

     

    Monday, October 15, 2007 5:44 PM
  •  

    Hmmm.  This is weird.  I'll try and reproduce this situation on one of my test machines, but first I need to know what operating system you're running this on.  Is it Win XP, Windows Server 2003, or Vista?


    Thanks!

    Richie

    Monday, October 15, 2007 7:28 PM
  • Windows XP SP2, fully up to date with security patches.  The machine is in a domain. 

     

    Other software installed includes Visual Studio 2005 and Visual C++ 2005 Redistributable, Visual Studio Team Explorer, .NET Framework 1.1, 2.0 and 3.0.   IIS is enabled of course.

     

    I also have (according to "Add/Remove Programs"):

       Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF)

       Visual Studio 2005 extensions for Windows Workflow Foundation

     

     

     

     

    Tuesday, October 16, 2007 12:41 PM
  • Hello,

     

    You may want to check this article out on blogs.msdn:

     

    http://blogs.msdn.com/wenlong/archive/2006/09/10/748294.aspx

     

    Hope this helps,

    Keith

     

    Tuesday, October 16, 2007 6:48 PM
  • Ahhh; thanks Keith, that was it.  Now I am seeing the .svc page normally (well, I am seeing an error telling me my security settings are wrong, but that passes for normal around here :-)

     

    [Summary for other readers: the problem was due to some corruption of the "IIS Metabase" caused by having an earlier pre-release copy of WCF on the machine. 

     

    The link provided in the previous post leads to a utility program that cleans this up.  Download that program and run it with administrator rights and everything will be corrected.]

    Tuesday, October 16, 2007 7:23 PM
  • I am having the exact same behaviour except inside visual studio 2008. If I browse to the .svc file I get the plain text. However VS 2k8 is running its internal web browser.

     

    I don't think the same issue is causing this, is it?

     

    I am really baffled for the last 2 days on this issue. I cannot get WCF to run in an ASP.NET application for the life of me. Everything builds but all I get is the raw ASP.NET markup spit out to the browser.

    Wednesday, April 16, 2008 4:10 AM
  • Can you try following the instructions at http://msdn2.microsoft.com/en-us/library/ms752252.aspx? The VS-hosted service shares some settings with IIS, and this may solve the problem.
    Wednesday, April 16, 2008 4:15 AM