Any examples or leads on how to implement Sencha Touch API with ASP .Net MVC?
Thanks
Atul
Any examples or leads on how to implement Sencha Touch API with ASP .Net MVC?
Thanks
Atul
No examples, but I'd consider this...
Use MVC to create a RESTful API, that returns JSON payloads. Stuff like
/people/index.json
/people/101.json
I find it helps to write some unit tests against those services, it will make your life easier for ruling out if problem is in Ext or MVC.
You can then use Senchas data stores, or it's plain Ajax requests to GET data to your MVC API. POSTS should be easy to do too.
The approach will be similar with ExtJS, you could check the samples there.
Hope this helps
Tobin
tobinharris.com
Leeds, UK
Co-author of NHibernate in Action
Likes iPhone, iPad, HTML5, .NET and Ruby on Rails
Developer and Founder at engineroomapps.com
Using Sencha Touch with ASP.NET MVC will no (or very little) different to using it with ExtJS. All your doing is calling your MVC Actions from the Sencha Stores and /or Ajax calls just as you would with a static json file or a PHP file.
In your MVC Action you should make sure your returning JSON data which can be interpreted by the Store. Something like this will return some data in the correct format from your ASP.NET..
That is untested but gives you the idea (it uses the JSON.NET library which i recommend you use as it makes converting objects to JSON very easy)Code:public ActionResult GetData() { Dictionary<string, string> myData = new Dictionary<string, string>(); myData.add("Test", "Value"); string jsonString = JsonConvert.SerializeObject(myData); new ContentResult { Content = jsonString, ContentType = "application/json" }; }
Hope this gets you further down the path!
Agreed. There's no special formula for using Touch/ExtJS with MVC. It follows the same pattern and there's plenty of posts on the forum about Ext with MVC.
Twitter - @evantrimboli
Former Sencha framework engineer, available for consulting.
As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.
Thanks for your prompt replies and specially explaining in detail.
Looks like we will be integrating with Sencha.
Need to understand more about licensing.
How do you get to tack on the '.json' at the end of each MVC Action? Must you have the .json suffix at the end of the URL?
You don't need to have the .json on the end - the .json is just the file extension of a JSON file. As long as your content type is being returned as "application/json" then you should be fine.
Since ASP.Net MVC 1 you have a type of Action named "JsonResult", instead of return an ActionResult on your method you should return a JsonResult. and with ASP.Net MVC you have a .ToJson() method in your objects wich make all the transformation you need.
your method should look like this:
PHP Code:
public JsonResult GetData()
{
Dictionary<string, string> myData = new Dictionary<string, string>();
myData.add("Test", "Value");
return myData.ToJson();
}
hope this help