开发者

What is the best way to render JSON for an ajax call using Sitecore?

开发者 https://www.devze.com 2023-03-20 01:21 出处:网络
What is the best way to render JSON for an ajax call using Sitecore? Google looks like it turns up a few posts noting how to serialize Sitecore objects which isn\'t 开发者_JS百科hard.

What is the best way to render JSON for an ajax call using Sitecore? Google looks like it turns up a few posts noting how to serialize Sitecore objects which isn't 开发者_JS百科hard.

Will returning JSON to a client-side ajax call require a new layout with a device with query params 'device=json' and a sublayout attached which returns serialized JSON?

Is it better to create a .aspx page which simply accesses Sitecore and returns serialized results?

Simply looking for a way to output JSON requested by a client-side AJAX call easily with Sitecore.


You've probably seen it before, but the solution you describe worked for this fellah. Setup correctly in theory you would just need one Layout which serializes the context item. Filtering out page content with AJAX in Sitecore

If you don't need or want to provide the option of serializing ALL content, or if perhaps you need to perform some business logic or other processing, you might look into MVC-enabling your solution and creating MVC actions to serve your JSON. If setup correctly, you can still have access to some Sitecore context values (e.g. Database and Language). c.f. Sitecore and ASP.net MVC and http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/10/Sitecore-MVC-Crash-Course.aspx

ASP.NET MVC is a great way to serve JSON.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号