c# - Dynamic data for JQuery in ASP.NET pages -
problem
i have pages need dynamic data website generate output users.
a simple solution aspx(php, ...) page generate data , create html page serving gui retrieving data first page , showing users. in method can call gui page example form1.aspx , data page form1.json.aspx. although method, not suitable when creating components it.
another method i'm using using same gui page call querystring retrieve data. page should check query string , if exists, generate data , remove else page. example method if call page form1.aspx, retrieve data, need call form1.aspx?json
here example of i'm doing:
protected void page_load(object sender, eventargs e) { if (request.querystring.tostring().indexof("json") == 0){ this.controls.clear(); response.clear(); // send pure data client } else { // render page gui } } however method becomes messy if add master page and/or inherit page template page. master pages can removed in page_preinit , adds method.
security controls cause problem, if user leaves page open long time until session expires attempt retrieve data fail cause security module redirect request login page.
next problem cannot consolidate component in package because needs modification in page (removing master page, clearing page components ...).
what i'm looking for:
1- i'm looking solution can call page , pure data (json or xml format) , doing run server side method generates data, don't have worry designer puts in master page or template.
2- think possible use axd extension don't have clue , couldn't find helping document either.
3- there better way of doing this. suggestion or solution improve appreciated.
page methods. check article: http://weblogs.asp.net/craigshoemaker/archive/2008/09/29/using-jquery-to-call-asp-net-ajax-page-methods.aspx or http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
wcf json service: http://www.codeproject.com/articles/327420/wcf-rest-service-with-json
other ways of doing using http handler. implement ihttphandler interface , register implementation in web.config file. later call using jquery ($.get / $.post):
edit op pointed out, in order access session state in page method should use webmethodattribute way:
[webmethod(enablesession = true)]
Comments
Post a Comment