This is a migrated thread and some comments may be shown as answers.

'Method Not allowed' error on client-side binding RadGrid using AjaxEnabledWcfService.

4 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Smruti Ranjan
Top achievements
Rank 1
Smruti Ranjan asked on 04 Oct 2012, 08:09 AM
Hi,

I have a RadGrid in my ASP.Net web form.
Now i want to bind this on client-side through a AjaxEnabledWCFService.
After all the implementations done it seems the data is being retrieved through the response
but rather than showing it in the grid it shows an message like "Method not allowed.".

I could not able to find the actual reason behind this error, and what is the cause for dat not being populated.

Here are the details of my implementations :-
I have added the particular service to the Script manager like below :-

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
         <Services>
                <asp:ServiceReference Path="~/services/CustomerListService.svc" />
         </Services>
        <Scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>


Then added the service to the RadGrid ClientEvents - DataBindings tag like below :-

 
<DataBinding SelectMethod="GetCustomers" Location="~/services/CustomerListService.svc"
                     SortParameterType="Linq" FilterParameterType="Linq">
                </DataBinding>


I have a service named CustomerListService with DataContract as order,
ServiceContract as GetCustomers() as below codes :-

Ex:

   
[ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class CustomerListService
    {
         
        [OperationContract]
        public List<Customer> GetCustomers()
        {
            CustomerData CustData = new CustomerData();
            System.Data.DataTable dt = CustData.GetCustomersList(1, 1, "");
 
            List<Customer> Customerist = new List<Customer>();//Here Customer is DataContract
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                Customer cust = new Customer();
                SetPropertiesFromOrderRow(cust, dr);//set all the property values from DataRow to Order
                CustomerList.Add(cust);
            }
 
            return CustomerList;
        }
    }


The settings in the configuration file are like below :-  

<endpointBehaviors>
   <behavior name="ClientSideBindingTest.services.CustomerListServiceAspNetAjaxBehavior">
    <enableWebScript />
   </behavior>
  </endpointBehaviors>
 
 <services>
  <service name="ClientSideBindingTest.services.CustomerListService">
   <endpoint address="" behaviorConfiguration="ClientSideBindingTest.services.CustomerListServiceAspNetAjaxBehavior"
    binding="webHttpBinding" contract="ClientSideBindingTest.services.CustomerListService" />
  </service>
 </services>

Please let me know if anyone having any suggestions here and also i need to know how to pass the parameter to the service method to
get the values as per the parameter supplied.

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 09 Oct 2012, 07:29 AM
Hi Smrutu,

You could try resolving you issue by following the steps and using the code provided in the help article and demo below. Note that if you your issue still persists it is possible that the problem is not related to the code but to the specific project setup. Additionally, you could try creating a new project and using the code from the demo in order to observe if you could successfully replicate the issue.

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Smruti Ranjan
Top achievements
Rank 1
answered on 02 Nov 2012, 07:37 AM
Hello Antonio Stoilkov ,

Thanks for your reply for pointing a direction towards the solution of this issue.

These links i was following previously, and by applying many work arounds i finally able to get the root cause behind the issue and its solution.

The issue was caught with enabling the Tracing in WCF. The root cause was i was not assigning the DateTime field if coming NULL from the DB and it was taking the default value as 01/01/0001 which is not in the DateTime range of the jSon datetime field and thats why it was throwing error and not displaying the data with showing the message like "method not allowed.".

So now this issue resolved by fixing this issue.

Thanks again,
Smruti
0
Smruti Ranjan
Top achievements
Rank 1
answered on 22 Jan 2013, 06:50 AM
Hi  Antonio ,

Thanks for your suggestions, i appreciate it but,
I got the solution for my question and here is the details described below :-

Reason : The main reason behind this "Method not allowed." could be caught after i enabled the tracing feature of the WCF by setting the configuration in the web.config file.
What it traced i am describing here :-

Description : I had a DateTime type field when i was assigning value from DB to this field NULL values are avoided to be assigned so for the fields not assigned a default value of '01/01/0001 00:00:000' is being automatically assigned to the field. But when this field is being passed to the jSon this date is the out of range of the json Date fields, which is causing the actual error here and it throws that exception and service breaks there.

Solution : The solution is simple, just i needed to make the DateTime field as Nullable so that it will take the NULL rather than assigning a default out of range value to the field and this fixed my issue.

Thanks to WCF tracing facility which helped me to track the exact error.
0
Antonio Stoilkov
Telerik team
answered on 24 Jan 2013, 11:23 AM
Hi Smruti,

Thank you for sharing the reason, description and the solution to your problem. I am happy that your issue is now resolved please do not hesitate to contact us again.

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Smruti Ranjan
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Smruti Ranjan
Top achievements
Rank 1
Share this question
or