PDA

View Full Version : Update large data with Ext.Ajax.Request



hieu79vn
3 Aug 2012, 1:56 AM
Hi

I want to send a big data to server. I know we can use parameter in Ajax Request. But I think maybe it's not secured and server may deny a long parameter.

Do we have other way to do this?
For example
Ext.Ajax.request({
url: '<%=WwwRoot%>/page.aspx',
method: 'POST',
data: ................... (here is the data sent to server and .... how can we get it on server? C#, ASP.NET)
scope: this,

Thank you

sword-it
3 Aug 2012, 3:23 AM
Hi hieu79vn,
Instead of using aspx page on the server side, you can use webservice provided by ASP.NET - .asmx page.
I am giving you can example how to send data to the webservice (.asmx page).

js code from where request will be sent -



Ext.Ajax.request({
url: '/webservice/MyService.asmx/AddUser' // AddUser is the webmethod name
// name of the fields will be same as we have arguments in the AddUser() in webservice
, params: {
name: 'xxxx'
, age: 23
, contactNo: 2222222222
}
, method: 'POST'
, headers: {
'content-type': 'application/json'
}
, success: function (data) {
// do any task
}
});



Now the server side code:
MyService.asmx



using System.Web;
using System.Web.Security;
using System.Web.Script.Services;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections;
using System.Collections.Generic;


[ScriptService]
public class RiskMgtService : WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
public string AddUser(string name, string age, string contactNo) // parameter will be same as we are sending the values in params config of Ajax.request
{
// do anything with data
}
}

hieu79vn
5 Aug 2012, 11:27 PM
Thank you sword-it I will try it

billtricarico
6 Aug 2012, 9:00 AM
Also make sure to set IIS to receive large amounts of POST data.

http://forums.iis.net/t/1189637.aspx



(http://forums.iis.net/t/1189637.aspx)