WCF 405 Method Not Allowed Crazy Error Help!
        Posted  
        
            by devmania
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by devmania
        
        
        
        Published on 2010-03-15T19:45:34Z
        Indexed on 
            2010/03/15
            19:49 UTC
        
        
        Read the original article
        Hit count: 1039
        
wcf
|asp.net-ajax
hi, i am going crazy i have read like 10s of articles also on stackoverflow about that i am calling webservice in restful way and should enable this in service and in webconfig, so i did that but as soon as i add the [WebGet()] Attribute i get this crazy error if i remove it then the service get called seamlessly
i am using
- VS 2010 RC 1
 - IIS 7
 - Windows 7
 
here is my code
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode    
=AspNetCompatibilityRequirementsMode.Allowed)]
public class Service2
{
[OperationContract]
[WebGet()]
public List<Table1> GetCustomers(string numberToFetch)
{
    using (DataClassesDataContext context = new DataClassesDataContext())
    {
        return context.Table1s.Take(numberToFetch).ToList( );
    }
}
}
and my ASPX page Code
<body xmlns:sys="javascript:Sys"   
    xmlns:dataview="javascript:Sys.UI.DataView">  
  <div id="CustomerView"   
      class="sys-template"  
      sys:attach="dataview"  
      dataview:autofetch="true"  
      dataview:dataprovider="Service2.svc"  
      dataview:fetchParameters="{{ {numberToFetch: 2} }}"  
      dataview:fetchoperation="GetCustomers">  
      <ul>  
          <li>{{name}}</li>  
      </ul>  
  </div> 
and my Web.config code
    <system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="Service2AspNetAjaxBehavior">
                <enableWebScript />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
        multipleSiteBindingsEnabled="true" />
    <services>
        <service name="Service2">
            <endpoint address="" behaviorConfiguration="Service2AspNetAjaxBehavior"
                binding="webHttpBinding" contract="Service2" />             
        </service>
    </services>
</system.serviceModel>
totally appreciate the help
© Stack Overflow or respective owner