asp.net - what is the function of HttpContext.Current.Request? -


1)when need use httpcontext (exclusively), please elaborate example if possible.

2)what following code do

internal string querystring( string name )  {      if ( httpcontext.current.request.querystring[name] == null )                 return string.empty;             else {                 return httpcontext.current.request.querystring[name].tostring(); } 

3)is there other alternative way avoid using httpcontext

q1:

httpcontext object encapsulates http-specific information individual http request. so, if need information receiving http request (for example in order query string parameter values, referral urls, user's ip address etc), need use httpcontext object. further more, object contains information of current request, response, server, session, cache, user , etc.

more information

usage , examples

  1. get current session id: httpcontext.session.sessionid
  2. get timestamp of current request: httpcontext.timestamp.tostring()

q2:

in code sample, trying value of query string parameter 'name'.

your dummy request url looks - http://www.yourdomain.com/something?name=querystringvalue

  • querystring parameter = name
  • querystring parameter value = querystringvalue

hope helps.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -