2009-10-27 17 views

Odpowiedz

6

public string to [string key] {get; }

Deklarowanie Typ: System.Web.HttpRequest Montaż: system.Web, Version = 2.0.0.0

public string this[string key] 
{ 
    get 
    { 
     string str = this.QueryString[key]; 
     if (str != null) 
     { 
      return str; 
     } 
     str = this.Form[key]; 
     if (str != null) 
     { 
      return str; 
     } 
     HttpCookie cookie = this.Cookies[key]; 
     if (cookie != null) 
     { 
      return cookie.Value; 
     } 
     str = this.ServerVariables[key]; 
     if (str != null) 
     { 
      return str; 
     } 
     return null; 
    } 
} 
+0

Kolejna użyteczna numer referencyjny: http://www.hanselman.com/blog/ASPNETParams CollectionVsQueryStringFormsVsRequestindexAndDoubleDecoding.aspx – smwikipedia

1

Wystarczy użyć Reflector i można zobaczyć go na własne oczy. Kolejność to QueryString, Form, Cookies, a następnie ServerVariables.

1

To z ASP site, ale nadal ma zastosowanie do ASP.NET:

Wszystkie żądania zmienne obiektów można dostępne bezpośrednio dzwoniąc żądanie (zmienna) bez nazwy zbiórki. W tym przypadku serwer Web przeszukuje zbiory w następującej kolejności:

  1. kwerendy
  2. Formularz
  3. Cookies
  4. Certyfikat klienta
  5. ServerVariables
+2

Reflector twierdzi, że "ClientCertificate" nie jest przeszukiwany w .Net 2.0. – David

Powiązane problemy