.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

jQuery & WCF Data Service - PUT Update - Rejected with 405 Method Not Allowed

Posted By:      Posted Date: September 12, 2010    Points: 0   Category :ASP.Net
I am writing a sample jQuery/WCF Data Service app to utilize OData, however I am getting a status code 405 - Method not allowed when I attempt to update an entity with a PUT Http method. I have configured my WCF Data Service as follows: public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("jCredentials_PINs", EntitySetRights.All); config.SetEntitySetAccessRule("jCredentials_PINTree", EntitySetRights.All); //config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } I am attempting to update the jCredentials_PINs table. My jQuery call to update the WCF Data Service is as follows:function UpdatePIN(selectedTreeNode, updateObj) { var url = dataService + "/jCredentials_PINs(guid'" + selectedTreeNode.get_value() + "')"; var json = JSON.stringify(updateObj); $.ajax({ url: url, data: json, type: "PUT", contentType: "application/json; charset=utf-8", timeout: 10000, dataType: "json", success: AjaxPINUpdateSuccess, error: AjaxPINUpdateFailure }); } function AjaxPINUpdateSu

View Complete Post

More Related Resource Links

MERGE using jQuery with a WCF Data Service

I'm a bit new to the whole asp.net thing so this is probably a silly question, but here it goes: I have created a WCF Data service based based on a ADO.net Entity--it's very basic: namespace raid{ public class allPeopleDataService : DataService< raid.raidEntities > { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } }} I've been successfully retrieving data using jquery's '$.getJSON' and inserting data using a modified $.ajax: $.ajax({url: "/allPeopleDataService.svc/lists",dataType: 'json',contentType: 'application/json',data: $jsonObj,processData: false,type: 'POST'}); I was reading the post at http://msdn.microsoft.com/en-us/library/cc668771.aspx and trying to use the MERGE method to update parts of the data with the following jquery jsont = { "__metadata": { "uri": "/allPeopleDataService.svc/lists(1)", "type":"raidModel.list" }, "list_name": "list blah blah" }; $.ajax({ url: "/allPeopleDataService.svc/lists(1)", dataType: 'json',

Sys.Data.DataContext.saveChanges method doesn't send update to server after DataServiceException ex

Hello,I have a page with a simple form that updates a single record in a table in my database.The database is accessed via WCF Data Services. To load and save data from/to the server, I usethe Sys.Data.DataContext object provided by the ASP.NET AJAX library. When the "save" button on theform is clicked, I use the saveChanges method of the Sys.Data.DataContext object to send all changes to the server.Also, at the server side, I use an interceptor that checks the "Price" fields of the record, and throws a DataServiceException exception when the contents of the field is a negative number.Both the JavaScript and the interceptor (in C#) are copied below.Here is the interesting thing:When I enter a negative price in the form, the interceptor throws the exception and my form shows an error message. Good.However, if I then make one of the other fields in the form a bit shorter (for example from "abcd" to "abc"),the saveChanges method doesn't send the data to the server. But it does call the success callback that I passed in to saveChanges, creating the impressionthat the data has been saved. This happens while the Price field is still negative. I used Fiddler to make sure thatno message is sent to the server. Also, the interceptor doesn't get executed.The weird thing is that if I make one of the fields a bit longer instead (for example &q

Need to create a service to allow client application to update their data



I want to create a  WCF Service to transfer data to our clients application(WPF).

The Data I am trying to send is as follows.

ID  Code          Description   unit    Rate

1   104200000   LIVE GOAT      NOS     25

2   104200000   LIVE GOAT2    NOS    25

3   104200030   LIVE GOAT3    KGS     10

4   104202030   Water             LTR      5

and so on till ~ 11000 records.

What I have done so far is. Created a service which return a list of data.


 public List<Classes.TariffData> GetTariffData()
var currentTariffData = new List<Classes.TariffData>();

using (var myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
const string query = "select a.ID,a.Code,a.Description,a.unit,a.rate,a.rate3 from tariff.dbo.tariffdata a, tariff.dbo.code_history b where a.id = b.id and b.endofvalidity is null";
using (var myCommand = new Sq

How to update Domain Service from Entity Data Model?


Hi guys,

So I'm using Entity data model to reflect my database and I generate Domain service from my Entity data model.

I understand that if I have changes in my database, I can just choose "Update Model from Database", but there is no "Update Domain service from Model" option available.

How should maintain my domain service? I'm not going to delete away it and regenerate it whenever there are some changes, right?

I need to know what if

- I add in new table in my database, how should I update from database-->model-->domain service?

- I add in new fields in my table, how should I update from database-->model-->domain service?


Trouble sending data to WCF service from JQuery


Hi there...I am calling a WCF service that is using webHttpBinding from a javascript JQuery call, such as:

        async: false,
        type: "POST",             
        url: varUrl,             
        data: varData,        
        contentType: "application/json; charset=utf-8",  
        dataType: "json",       
        processdata: true,
        success: function(msg) {
        error: ServiceFailed

varData is {"x1":3,"x2":"Blah"}

Signature at the service side is:

public string File_Load(short fileType, string name)

Will it be a good practice to submit form data through web service method?



I am trying to submit my form's data to database using asmx Web Service method(Through AJAX extension methods i.e., Script callback method). My form contains lot of data, though only text data.This will be a very fast process,but still i want to get some advice from you expert persons that should i processd in the same way ?Or should i submit form data in the traditional way ?

Please give proper reason for your answer.

JQuery Autocomplete Call WCF Service Method


I am trying to use the below code to call a wcf service method for Autocomplete functionality in a TextBox.  I have written the following query:

$(document).ready(function () {
            $("#<%= txtCompany.ClientID %>").autocomplete(http://localhost/PieScore/PieScore.Application.Services/EmployeeService.svc/GetTestCompanyList, {
                dataType: 'json',
                parse: function (data) {
                    var items = data.d;
                    var parsed = [];
                    for (var i = 0; i < items.length; i++)
                        parsed[i] = {

Calling a data-driven web service method asynchronously


I am trying to write a Windows Service which will call web service methods based on a run schedule.  I have setup a ‘schedule’ table which holds the name of the web service method and some scheduling details (e.g. run every day at 0200).  I am using VS 2005/vb.net.

My service creates a timer which runs every minute and when the timer is fired the schedule table is read and  any entries which are due to fire are actioned.  This could mean multiple methods being fired at the same time.  As some of the methods are overnight batch processes and may take some time, I don’t want processes to wait for others to finish before being actioned.  As the methods themselves write to the system log to report their success or failure the scheduling service does not care whether the job fails or not – it is simply doing a ‘fire and forget’ exercise.

What I need is some code which will fire a data-driven web service method asynchronously.

I have investigated two types of method call.  The first is a simple InvokeMethod:-

mywebservice.GetType().InvokeMember(ScheduleRow("WebMethod").TOString(),(Reflection.BindingFlags.InvokeMethod Or Reflection.BindingFlags.IgnoreReturn), Nothing, mywebservice, Nothing)

The second is an asynchronous call:-

Dim asyncCall as New AsyncCallB

Update Query ? Incorrect use of the xml data type method 'modify'. A non-mutator method is expecte


I have a column of ntext da


ta type and NOT XML. It stores all xml data. I need to update xml node in the records. It throws an error saying "Incorrect use of the xml data type method 'modify'. A non-mutator method is expected in this context."

 begin transaction
declare @Cps_Id int;
set @Cps_Id = 236;
declare @Cps_Message nvarchar(1024);
set @Cps_Message = 'updating cpsia message with smoking';

update table_name
set column_name = CONVERT(xml,column_name).modify('replace value of (/root/ProductInformation/CPSIA/CpsiaDetails/Item[CpsiaId=sql:variable("@Cps_Id")]/CpsiaMessage/text())[1] with sql:variable("@Cps_Message")')
WHERE Convert(xml,column_name).exist('/root/ProductInformation/CPSIA/CpsiaDetails/Item[CpsiaId=sql:variable("@Cps_Id")]')=1


Sample XML:

<strong><root> <ProductInformation> <Name> Truck with Battery Charger</Name> <Description>Fr.</Description> <CPSIA> <CpsiaDetails> <Item> <CpsiaId>456</CpsiaId> <CpsiaMessage>waring</CpsiaMessage> </Item> <Item> <CpsiaId>236</CpsiaId> <CpsiaMessage>to health</CpsiaMessage> </Item&

Post JSON data to WCF RESTful Service using jQuery

The POST request method is basically designed to post data to a web server for storage. That's why its normally used when submitting a complete form. In this WCF RESTful service tutorial, I'll try to explain how we can post JSON data to a WCF RESTful service using jQuery Ajax call with POST type. We discussed about "POST" HTTP verb in previous WCF tutorials but we didn't use it in our implementation. Purpose of this article is to understand "POST" request with complete implementation for a specific operation.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Posting data to ASMX and return Object for jQuery


I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.

1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?

2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.

Here is my code:

User Profile Page:

Status: <asp:Label ID="status" runat="server"></asp:Label><span style="font-size:.7em;"><asp:Label ID="statustime" runat="server"></asp:Label></span><br />
<textarea id="statusBox" rows="3" cols="40"></textarea><br />
<input type="button" value="Update Status" onclick="SetStatus(); return false;

WCF Data Service to JSON example? v4


I would like to take WCF Data Service and produce JSON output to consume on various mobile apps.

Can anyone give me a how-to on the JSON part?  I.e., what is different than normal XML outut?



Data Points: Service-Driven Apps With Silverlight 2 And WCF


Here John Papa demonstrates how to build a Silverlight 2 user interface that communicates through WCF to interact with business entities and a database.

John Papa

MSDN Magazine September 2008

SQL Server CE: New Version Lets You Store and Update Data on Handheld Devices


Handheld device users need to be able to synchronize with a main data store when it's convenient and, preferably, when the back-end database server isn't busy. SQL Server 2000 Windows CE Edition allows you to build a traveling data store that can be displayed and run on a variety of devices. SQL Server CE supports a subset of the full SQL Server package, and can be used as a standalone server or in tandem with SWL Server and IIS. The architecture of SQL Server CE, along with data manipulation, synchronization, and connectivity issues, are discussed in this article. Topics such as making your data public, choosing the right type of replication, and handling errors are also covered.

Paul Yao and David Durant

MSDN Magazine June 2001

Writing Data to database with jQuery Forms, ASMX Webservice, & JSON - help!



Can someone point me in the right direction on how to submit data from a jQuery form to a ASMX webservice? I have gotten everything on the form ready to be submitted to the database and now I am stuck on how to send it over using $.ajax(). Everything I have read tells me how to get data from a webservice and display it with jQuery, but not the other direction nor how to access the json data within the within the webservice service(similar to a Request.Form approach with ASP.NET forms).

In other words: 

1. What do I need to do to my webservice to make sure it can receive data from the jQuery form. 

2. What do I need to do in jQuery to receive an acknowledgement the save on the server side was successful. 

I can explain more if need be, but if there is a comprehensive tutorial on not only reading, but also WRITING data with jQuery, JSON, etc. I would love to get pointed in that direction. 

insert the data in database using gridview jquery



I want to use gridview and bind the data and after i want insert the data in database using jquery,

below the link i got for delete


but i want the sample example for insert  row from gridivew and add the database.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend