<p>Hello all,</p> <p>I am creating an asp.net MVC site and i have combinded it with sench touch library for the presentation side of things. I have an issue with accessing the 'request payload' on the MVC site.</p> <p>I have added an attachment that shows the
json that is contained in the request payload section in chrome.</p> <p>Usually in the sencha touch tools i add an extra parameter to the control and that is then passed back to the controller and everything is good. In this situation the data is held in the
request payload and i am unsure of how to get at that information from the MVC side of things.</p> <p>Does anyone know how to get at this ?</p> <p></p>
I believe the sencha library only works in web kit enabled browsers, so at the moment it's chrome and safari, I have tried to use sedna touch with fire fox but I get a few webkit based errors so for now I'm focusing on the chrome and safari browsers (these
are the target platforms) I will attach image when I'm back at my desk:)
Above is the screen shot that shows the request payload.
In sencha this is all i'm doing, creating 2 records and then adding them to the store, then sync-ing the store which forces the request back to the server.
var sel = Ext.ModelMgr.create({TraumaReviewId: 2, TraumaCategoryId: 46}, 'Trauma.Data.Models.CategorySelection');
var sel2 = Ext.ModelMgr.create({TraumaReviewId: 2, TraumaCategoryId: 47}, 'Trauma.Data.Models.CategorySelection');
Trauma.Data.Stores.CategorySelectionStore.add(sel);
Trauma.Data.Stores.CategorySelectionStore.add(sel2);
Trauma.Data.Stores.CategorySelectionStore.sync();
your request is doing a post with a url and a json content body. if you like the json tab you shoudl see the json structure. if you haven't define a .net model to receive the json. then if you use the standard route mapping you have
Ok, never thought of that, I will give that a whirl. The_dc parameter is something chrome adds in for debugging purposes. So I'll try a method with just the Id and the model. I gather the model would have to be similar to the json being parsed ?
Thanks for the help, I had a go at what you said. I tried to keep the model as close to the json as possible.
I added a controller that just accepted my Model. Here is the model and controller.
//Models
public class RequestPayload
{
public List<record> records;
}
public class record
{
public int TraumaReviewId { get; set; }
public int TraumaCategoryId { get; set; }
public int Id { get; set; }
}
//Controller
public ActionResult Handler(Models.RequestPayload obj)
{
//Do work
}
When i debug i do hit the controller and there is a Request Payload object but the internal list of records is null. Is there something i need to do ?
frostfang
Member
556 Points
217 Posts
Request Payload in chrome
Oct 02, 2011 11:15 PM|LINK
Intranet Developer
ZafarYousafi
Contributor
2542 Points
401 Posts
Re: Request Payload in chrome
Oct 03, 2011 02:29 AM|LINK
Where is json?
ignatandrei
All-Star
137649 Points
22143 Posts
Moderator
MVP
Re: Request Payload in chrome
Oct 03, 2011 03:05 AM|LINK
Did you try with FF/IE and it works? Only in Chrome does not?
( and please wrote the script)
frostfang
Member
556 Points
217 Posts
Re: Request Payload in chrome
Oct 03, 2011 01:41 PM|LINK
Intranet Developer
frostfang
Member
556 Points
217 Posts
Re: Request Payload in chrome
Oct 03, 2011 01:46 PM|LINK
Intranet Developer
frostfang
Member
556 Points
217 Posts
Re: Request Payload in chrome
Oct 04, 2011 03:18 AM|LINK
Intranet Developer
frostfang
Member
556 Points
217 Posts
Re: Request Payload in chrome
Oct 04, 2011 03:22 AM|LINK
Above is the screen shot that shows the request payload.
In sencha this is all i'm doing, creating 2 records and then adding them to the store, then sync-ing the store which forces the request back to the server.
var sel = Ext.ModelMgr.create({TraumaReviewId: 2, TraumaCategoryId: 46}, 'Trauma.Data.Models.CategorySelection'); var sel2 = Ext.ModelMgr.create({TraumaReviewId: 2, TraumaCategoryId: 47}, 'Trauma.Data.Models.CategorySelection'); Trauma.Data.Stores.CategorySelectionStore.add(sel); Trauma.Data.Stores.CategorySelectionStore.add(sel2); Trauma.Data.Stores.CategorySelectionStore.sync();Intranet Developer
bruce (sqlwo...
All-Star
37594 Points
5573 Posts
Re: Request Payload in chrome
Oct 04, 2011 05:01 AM|LINK
your request is doing a post with a url and a json content body. if you like the json tab you shoudl see the json structure. if you haven't define a .net model to receive the json. then if you use the standard route mapping you have
/categoryselection/handler/0 => {controller}/{action}/{id}
querystring _dc = <number string>
try
public ActionResult handler(int id, string _dc, MyJsonObject model)
frostfang
Member
556 Points
217 Posts
Re: Request Payload in chrome
Oct 04, 2011 11:38 AM|LINK
Intranet Developer
frostfang
Member
556 Points
217 Posts
Re: Request Payload in chrome
Oct 04, 2011 11:10 PM|LINK
Thanks for the help, I had a go at what you said. I tried to keep the model as close to the json as possible.
I added a controller that just accepted my Model. Here is the model and controller.
//Models public class RequestPayload { public List<record> records; } public class record { public int TraumaReviewId { get; set; } public int TraumaCategoryId { get; set; } public int Id { get; set; } } //Controller public ActionResult Handler(Models.RequestPayload obj) { //Do work }When i debug i do hit the controller and there is a Request Payload object but the internal list of records is null. Is there something i need to do ?
Intranet Developer