c# - RouteData.Values["xxx"] generates error inside asp.net user Control -


i trying update asp.net webform based website use routing feature failing fix 1 error inside usercontrol.ascx.

i can access query string value in main page using routedata.values["language"].tostring() same fails when need use query string value inside user control.

i tried using httpcontext.current.request.requestcontext.routedata.values["language"].tostring();

but no luck.

below code sample trying catch querystring

int langid = 1; int articleid = 0; int pageid = 0; int issueid = 0; int categoryid = 0; string language = string.empty;     if (string.isnullorempty(request["pageid"]))     {          language = httpcontext.current.request.requestcontext.routedata.values["language"].tostring();         langid = helper.getlanguageid(language);         articleid = int.parse(httpcontext.current.request.requestcontext.routedata.values["aid"].tostring());         pageid = int.parse(httpcontext.current.request.requestcontext.routedata.values["pageid"].tostring());         issueid = int.parse(httpcontext.current.request.requestcontext.routedata.values["issue"].tostring());     }     else     {         language = request["language"];         langid = helper.getlanguageid(language);         articleid = int.parse(request["aid"]);         pageid = int.parse(request["pageid"]);         issueid = int.parse(request["issue"]);     } 

i getting following error statement language = httpcontext.current.request.requestcontext.routedata.values["language"].tostring();

error message:

system.nullreferenceexception caught   message=object reference not set instance of object.   source=app_web_odw0cnkk 

i appreciate in regarding or how around problem

use below:

httpcontext.current.request.requestcontext.routedata.values["xxxxxx"] 

thx: https://social.msdn.microsoft.com/forums/tr-tr/c53d8d15-19d0-455b-b5a9-3d64d0793f99/usercontrol-iinde-routedatavaluesid?forum=aspnettr&prof=required


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -