ASP.NETの6つの内蔵オブジェクトのまとめ

15533 ワード

ASP.NETの組み込みオブジェクトの紹介:
1.Response
2.Request
3.Server
4.Application
5.Session
6.Cookie
1.  
Response
:
Response
オブジェクトは、ブラウザへのデータの出力、別のブラウザへのリダイレクトなど、クライアントへのデータの出力に使用されます.
URL
またはブラウザに出力
Cookie
ファイル.クラス名は
httpResponse
.
Write()            
BufferOutPut         
Clear()     
Flush()            
Redirect()       
End()          
WriteFile() 
(  :    ,        。)
(1)Response.Write         
Response.Write (        )
Response.Write("<script language=javascript>alert('    ASP.NET')</script>") 
Response.Write("<script>window.open('WebForm2.aspx')</script>") 
(2)Response   Redirect                URL ,         。
  :Response.Redirect("http://www.163.net/")
(3) Response.End()         
(4)Response.WriteFile(FileName)
FileName                 
2.Request 
                        Request                      ,   HTML   Post  GETCookieRequest   Page       ,                     。     HttpRequest
(1)  Request.Form      
<Form></Form>
  :        “postGetPost                   
(2.)  Request.QueryString      
   Request   QuerySting       HTTP           。     ,    
            http://localhost/aaa.aspx?uid=tom&pwd=abc            
    。  :        “Get”。
3.Request.Form         PostRequest.QueryString     
               Get   ,    ,       。
Request(“   ”)
4.Request.ServerVariables("      ")
UserHostAddress,Browser,Cookies,ContentType,IsAuthenticated,Item,Params
3.Server 
    Server                     .     HttpServerUtility.
    
    MachineName:           。 
    ScriptTimeout:         (   )。
    CreateObject    COM 
    Execute             aspx
    HtmlEncode                HTML
    HtmlDecode  HTML          ,          。
    MapPath     Web 
    Transfer         ,            。
UrlEncode    URL URL   Web              
 HTTP 
    UrlDecode       URL       ,          。
    UrlPathEncode   URL            URL   ,          。
    
    Server.HtmlEncode(HTML)
    
    Server.HtmlDecode(HTML)
    (1)Server   MapPath                      Web         
        
      Server.MapPath(“    ”)
           String FilePath
           FilePath = Server.MapPath(“/”)
           Response.Write(FilePath)
4.Application 
     Application                        ,     、    、          。                   ,                。  Application
(1)    Application       
//  Application    
   Application(“  ”) =  
    
   Application(“  ”, )
   //  Application    
       = Application(“  ”)
    = Application.Item(“  ”)
    = Application.Get(“  ”)
   //  Application    
   Application.Set(“  ”,  )
   //     
   Application.Remove(“  ”,  )
   //     
   Application.RemoveAll()
    Application.Clear()
(2)                  Application  
  Application    ,          。 
HttpApplicationState         Lock   UnlockApplication         ,                   。
//       
Application.Lock()
Application(“  ”) =  
Application.Unlock()
Lock   UnLock 
(3)   Application   
 ASP.NET                   ――Global.asax  ASP.NET  ASP.NET HTTP 
Global.asax      75    Application   
       
Application_Start            
Application_BeginRequest            
Application_AuthenticateRequest                 
Application_Error          
Application_End           
5.Session 
     Session   ,                       。 
Session   .NET   HttpSessionState ,  “    ”,                。
Session                    aspx    ,       ,             。             ,Session
    WebApplicationSession Session      ,            ,    ,             SessionSession
1
     
     Session ("  ") =  
       
     Session.Add( "  " ,  )
2
    
      = Session ("  ") 
     
      = Session.Item("  ")
3
    
    Session.Remove("  ")
4
    
    Session.RemoveAll()
      
    Session.Clear()
5
    
    Session.Abandon()
6)           ,      。
    
    Session.TimeOut =   
    Global.asax     2      Session   
           
    Session_Start         
    Session_End         
6.Cookie 

Cookie
Webサーバがユーザーのハードディスク(HDD)に保存するテキストです.Cookieは、Webサイトがユーザーのパソコンに情報を保存し、その後それを取り戻すことを許可します.情報の断片は「キー/値」ペアとして格納される.
Cookie
クライアントのハードディスク(HDD)に保存するテキストファイルで、特定のクライアント、セッション、またはアプリケーションに関する情報を格納することができる.NETではHttpCookieクラスに対応しています.
Cookieには、セッションCookie(Session Cookie)と持続性Cookieの2種類があります.前者は一時的であり、セッション状態が終了すると存在しない.後者は、Cookieがユーザのコンピュータにテキストファイルとして格納される前に、期限切れが決定された期限切れを有する.
サーバ上でCookieを作成してクライアントに出力するには、Responseオブジェクトを使用します.
Response
オブジェクトはCookiesという集合をサポートし、Cookieオブジェクトをその集合に追加してクライアントにCookieを出力することができます.RequestオブジェクトのCookiesコレクションからCookieにアクセスします.
本文は“成長の記憶録”のブログから出て、転載して作者と連絡してください!