jQuery/JON/PHP对象到C#方法


jQuery/JSON/PHP object to C# method

嘿,伙计们,我是JSON的新手,我正在使用一个用PHP和jQuery编写的示例(http://wil-linssen.com/entry/extending-the-jquery-sortable-with-ajax-mysql/)。

我想做的是将序列化的"order"对象用于C#方法,就像上面的例子中PHP使用的一样。

所以jQuery的代码是:

<script type="text/javascript"> 
// When the document is ready set up our sortable with it's inherant function(s) 
$(document).ready(function() { 
  $("#test-list").sortable({ 
    handle : '.handle', 
    update : function () { 
      var order = $('#test-list').sortable('serialize'); 
      $("#info").load("process-sortable.php?"+order); 
    } 
  }); 
}); 
</script>

而不是将"order"对象传递给要在PHP中处理的处理程序,如:

<?php 
/* This is where you would inject your sql into the database 
but we're just going to format it and send it back 
*/ 
foreach ($_GET['listItem'] as $position => $item) : 
  $sql[] = "UPDATE `table` SET `position` = $position WHERE `id` = $item"; 
endforeach; 
print_r ($sql); 
?>

我想做完全相同的事情,但使用C#4.0在同一页面中的方法中处理对象。这可能吗?有人能告诉我怎么做吗?

编辑:我正在使用ASP.NET WebForms&C#4

非常感谢!

我认为你有一个漏洞。。SET position = $position,因为攻击者可以传递任意的get变量名。不完全是一个答案,但C#版本应该考虑这样做,而不是"完全相同的事情":)