c# - How to use Routing in asp.net 3.5 in web form -
i have used following code, not able access querystring ......
public class routehandler : iroutehandler { string _virtualpath; public routehandler(string virtualpath) { _virtualpath = virtualpath; } public ihttphandler gethttphandler(requestcontext requestcontext) { foreach (var value in requestcontext.routedata.values) { //requestcontext.httpcontext.items[value.key] = value.value; // requestcontext.httpcontext. //system.web.httpcontext.items[value.key] = value.value; } return (page)buildmanager.createinstancefromvirtualpath(_virtualpath, ypeof(page)); }
global.asax.............
private void registerroutes(routecollection routes) { routes.add("home", new route("home", new routehandler("default.aspx"))); datatable dt = getmyurl(); if (dt != null && dt.rows.count > 0) { foreach (datarow dr in dt.rows) { try { routes.add(dr["tag"].tostring() + "/" + dr["ntag"].tostring(), new route("{pid}/{cid}", new routehandler("~/test1/test1.aspx"))); } catch (exception exx){} } } }
now not able querystring. think custom routehandler not coded. have button on default page redirect page
response.redirect(dt.rows[0]["tag"].tostring() + "/" + dt.rows[0]["ntag"].tostring());// response.redirect("goa/agra");
please me.
following code worked me..
page.routedata.values["id"]
Comments
Post a Comment