Explore Microsoft MVC Environment Variables

We start MVC3 example with exploring/listing Environment Variables contains application sessionid, cockie, configuration, browser, etc… details

We try to finish this quest only by Controller without including unnecessary cosmetic things (view :D)

Create Controller: QueryStringController

public class QueryStringController : Controller
{
  public ActionResult Index()
  {
    Parameters();
    return Content("Index page is called");
  }

  [NonAction]
  public void Parameters()
  {
     foreach (string key in Request.Params.Keys)
     {
       Response.Write(string.Format("<strong>{0}:</strong> {1}<br/>", key, Request[key]));
      }
  }
}

HIT: http://localhost/querystring/index

———————————————————————————————————————————

We can make this above controller even shorter remove [NonAction], use Parameters methode as Action

public class QueryStringController : Controller
{
  public void Parameters()
  {
    foreach (string key in Request.Params.Keys)
    {
      Response.Write(string.Format("<strong>{0}:</strong> {1}<br/>", key, Request[key]));
    }
  }
}

HIT: http://localhost/querystring/Parameters

Environment Variables

__atuvc: 9%7C52%2C2%7C1
Nop.customer: 51ceb03d-b130-49ce-a0af-640f745c8e14
ASP.NET_SessionId: 5emy123x0tn2tnzvlev3arrc
ALL_HTTP: HTTP_CACHE_CONTROL:no-cache HTTP_CONNECTION:keep-alive HTTP_PRAGMA:no-cache HTTP_ACCEPT:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_CHARSET:ISO-8859-1,utf-8;q=0.7,*;q=0.3 HTTP_ACCEPT_ENCODING:gzip,deflate,sdch HTTP_ACCEPT_LANGUAGE:en-US,en;q=0.8 HTTP_COOKIE:__atuvc=9%7C52%2C2%7C1; Nop.customer=51ceb03d-b130-49ce-a0af-640f745c8e14; ASP.NET_SessionId=5emy123x0tn2tnzvlev3arrc HTTP_HOST:localhost:58550 HTTP_USER_AGENT:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
ALL_RAW: Cache-Control: no-cache Connection: keep-alive Pragma: no-cache Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Cookie: __atuvc=9%7C52%2C2%7C1; Nop.customer=51ceb03d-b130-49ce-a0af-640f745c8e14; ASP.NET_SessionId=5emy123x0tn2tnzvlev3arrc Host: localhost:58550 User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
APPL_MD_PATH:
APPL_PHYSICAL_PATH: C:\bhumip_pro\EF4MVC\MvcApplication1\
AUTH_TYPE:
AUTH_USER:
AUTH_PASSWORD:
LOGON_USER: VIBHUTI-PC2\vibhuti
REMOTE_USER:
CERT_COOKIE:
CERT_FLAGS:
CERT_ISSUER:
CERT_KEYSIZE:
CERT_SECRETKEYSIZE:
CERT_SERIALNUMBER:
CERT_SERVER_ISSUER:
CERT_SERVER_SUBJECT:
CERT_SUBJECT:
CONTENT_LENGTH: 0
CONTENT_TYPE:
GATEWAY_INTERFACE:
HTTPS:
HTTPS_KEYSIZE:
HTTPS_SECRETKEYSIZE:
HTTPS_SERVER_ISSUER:
HTTPS_SERVER_SUBJECT:
INSTANCE_ID:
INSTANCE_META_PATH:
LOCAL_ADDR: 127.0.0.1
PATH_INFO: /querystring/index
PATH_TRANSLATED: C:\bhumip_pro\EF4MVC\MvcApplication1\querystring\index
QUERY_STRING:
REMOTE_ADDR: 127.0.0.1
REMOTE_HOST: 127.0.0.1
REMOTE_PORT:
REQUEST_METHOD: GET
SCRIPT_NAME: /querystring/index
SERVER_NAME: localhost
SERVER_PORT: 58550
SERVER_PORT_SECURE: 0
SERVER_PROTOCOL: HTTP/1.1
SERVER_SOFTWARE:
URL: /querystring/index
HTTP_CACHE_CONTROL: no-cache
HTTP_CONNECTION: keep-alive
HTTP_PRAGMA: no-cache
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP_ACCEPT_ENCODING: gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_COOKIE: __atuvc=9%7C52%2C2%7C1; Nop.customer=51ceb03d-b130-49ce-a0af-640f745c8e14; ASP.NET_SessionId=5emy123x0tn2tnzvlev3arrc
HTTP_HOST: localhost:58550
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s