none
failed at testing a WCF service

    Question

  • I am reading "Pro c# 2010 and the .NET 4 platform", and have difficulty follow an code example.

    Here is what I did:

    1. New->web site->WCF service. named it AutoLotWCFService

    2. website->add reference to a data access library built before this, the library named AutoLotDAL.dll

    3. rename the generated IService.cs to IAutoLotServerice.cs, delete the code, add servicecontract, operation contract and data contract.

    4. rename the generated Service.cs to AutoLotServeice.cs, delete the code, put in connection string and some function implementation.

    5. edit Service.svc to reflect the correct service name and codebehind.

    6. didn't make any changes to the web.config

    7. then the book said you can tested it using "wcftestclient http://localhost/AutoLotWCFService/Service.svc"

    But it failed in adding service.

    If I try to run in directly in visual studio 2010, it will show me the following error. I follow some advice I found and edit the applicationHost.Config, change name="modules" line from "deny" to "allow". Problem still there.

    Any idea? I am very new to this, any help is appreciated.

    HTTP Error 500.19 - Internal Server Error

    Module IIS Web Core
    Notification BeginRequest
    Handler Not yet determined
    Error Code 0x80070021
    Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
    Config File \\?\C:\inetpub\wwwroot\testWCFService\web.config
    Requested URL http://localhost:80/testWCFService/
    Physical Path C:\inetpub\wwwroot\**WCFService\
    Logon Method Not yet determined
    Logon User Not yet determined
    <fieldset><legend>Config Source</legend>
       18:   <system.webServer>
       19:     <modules runAllManagedModulesForAllRequests="true"/>
       20:   </system.webServer>
    
    </fieldset>
    Wednesday, February 08, 2012 8:46 PM

Answers

  • An IIS server has one or more web sites. A web site has one or more virtual applications. Your service is likely hosted in a virtual application, not in the root site. But the root web site's web.config still affects your service. That's why you need to check there as well. If you open IIS Manager, you'll see the hierarchy.

    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.

    • Marked as answer by Yi-Lun Luo Wednesday, February 15, 2012 9:53 AM
    Friday, February 10, 2012 2:35 AM

All replies

  • Pin,

    I'm not sure what is going wrong, but I would try going through the Getting Started Tutorial (http://msdn.microsoft.com/en-us/library/ms734712.aspx) to verify your system is set up correctly. If a simple service like the one created in the Getting Started Tutorial doesn't work, that would lead me to believe there is a problem with your machine's setup. Please ensure that WCF has been registered with IIS by running the ServiceModelReg command (http://msdn.microsoft.com/en-us/library/ms732012.aspx) and the ASP_REGIIS command (http://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx).

    Please let me know what you find.

    Michael Green
    WCF Documentation Team

    Wednesday, February 08, 2012 9:23 PM
  • Michael,

    Thank you for your reply. I will go ahead and try the sample.

    Just let you know that I've already run ServiceModeReg and aspnet_regiis command in my windows\Microsoft .net\framework64\v4.***\ folder, probably also in framework\v4.** folder (not very sure about that). I really tried a lot of things.

    I will get back to you.

    Pin

    Wednesday, February 08, 2012 9:39 PM
  • You need to check few things 


    Do the following in your web.config file 


    Change all of the following values located in section <configSections> --> <sectionGroup name="system.webServer">


    change the following value from "Deny" to "Allow"
    <section name="handlers" overrideModeDefault="Deny" />


    change the following value from "Deny" to "Allow"
    <section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" /> 


    Also lock at the configuration file and its setting in the following location. May be it is overwriting in the machine level configuration file. 


    %windir%\system32\inetsrv\config\

    Tanvir Huda Application Architect/Consultant

    Thursday, February 09, 2012 2:02 AM
  • Tanvir,

    Thank you for your reply. My web.config file was generated by VS2010 when I new the WCF service. The book I am following doesn't make any changes to it, it looks like this, doesn't have any of the sections you mentioned. I've already change %windir%\system32\inetsrv\config\applicationHost.config file's "modules" and "Handlers" from "deny" to "allow". 


    <configuration>
      <system.web>
        <compilation debug="false" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
    </configuration

    Thursday, February 09, 2012 3:48 AM
  • Hello, check your IIS web site (not the virtual application)'s web.config, as well as machine.config, and web.config under the C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config folder (modify the path if your Windows is not on disk C, or you're using 32 bit OS, or you're using an earlier version of .NET). Make sure you don't have "Deny" on modules section in any of those files.

    <section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.

    Thursday, February 09, 2012 12:12 PM
  • Thanks Yi-Lun.

    Sorry I am very new to this field. What is "check your IIS web site (not the virtual application)'s web.config"? I've checked C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config and web.config, none of them have  

    <section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />

    I've changed that line in applicationHost.config, but problem still exists.


    Thursday, February 09, 2012 2:13 PM
  • An IIS server has one or more web sites. A web site has one or more virtual applications. Your service is likely hosted in a virtual application, not in the root site. But the root web site's web.config still affects your service. That's why you need to check there as well. If you open IIS Manager, you'll see the hierarchy.

    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.

    • Marked as answer by Yi-Lun Luo Wednesday, February 15, 2012 9:53 AM
    Friday, February 10, 2012 2:35 AM