Select the product you need help with
เหตุใด และอย่างไรเซสชันได้เข้ารหัสเป็น reused ใน ASP.NETหมายเลขบทความ (Article ID): 899918 - ผลิตภัณฑ์ที่เกี่ยวข้องในบทความนี้ บทนำบทความนี้อธิบายวิธีการ และเหตุใดรหัสเซสชัน ASP.NET ที่ Microsoft ใช้ ข้อมูลเพิ่มเติมสถานะของเซสชัน ASP.NET เป็นเทคโนโลยีที่ช่วยให้คุณเก็บข้อมูล ฝั่งเซิร์ฟเวอร์ เฉพาะของผู้ใช้ โปรแกรมประยุกต์เว็บสามารถใช้ข้อมูลนี้เพื่อประมวลผลการร้องขอจากผู้ใช้ซึ่ง instantiated สถานะเซสชัน ผู้ใช้สถานะเซสชันถูกกำหนด โดยมีรหัสของเซสชัน ID เซสชันได้มีการจัดส่ง โดยใช้หนึ่งในวิธีการต่อไปนี้:
เมื่อผู้ใช้ก่อน เปิดเว็บเบราว์เซอร์ของตน และไปยังเว็บไซต์ที่ใช้สถานะเซสชัน ASP.NET คุกกี้ถูกส่งไปยังเบราว์เซอร์ มีชื่อ "ASP.NET_SessionId" และค่า 20 อักขระ เมื่อผู้ใช้ภายในโดเมน DNS เดียวกันค้น เว็บเบราว์เซอร์ยังคงมีอยู่เพื่อที่ส่งคุกกี้นี้กับโดเมนที่จะถูก sourced ตัวอย่างเช่น app1.tailspintoys.com และ app2.tailspintoys.com เป็นโปรแกรมประยุกต์ ASP.NET ทั้งสอง ถ้าผู้ใช้ไปยัง app1.tailspintoys.com และไป app2.tailspintoys.com แอปพลิเคชันทั้งสองจะใช้คุกกี้ที่เหมือนกันและหมายเลขเซสชันเดียวกันเพื่อติดตามสถานะเซสชันของผู้ใช้ภายในแต่ละแอพลิเคชัน โปรแกรมประยุกต์ไม่ร่วมสถานะเซสชันเดียวกัน โปรแกรมประยุกต์รหัสเซสชันที่ใช้ร่วมกันเท่านั้น ดังนั้น คุณสามารถที่นำมาใช้เซสชันที่รหัสหลายสาเหตุ ตัวอย่างเช่น ถ้าคุณนำมาใช้เซสชันรหัส คุณไม่จำเป็นต้องดำเนินการต่อไปนี้:
เมื่อคุณใช้โหมดสภาวะของเซสชันในกระบวนการ ออบเจ็กต์สถานะเซสชันเหล่านี้ถูกเก็บไว้ใน HttpCache The HttpCache supports a callback method when the following conditions are true:
When you abandon a session, the session ID cookie is not removed from the browser of the user. Therefore, as soon as the session has been abandoned, any new requests to the same application will use the same session ID but will have a new session state instance. At the same time, if the user opens another application within the same DNS domain, the user will not lose their session state after theAbandonmethod is called from one application. Sometimes, you may not want to reuse the session ID. If you do and if you understand the ramifications of not reusing the session ID, use the following code example to abandon a session and to clear the session ID cookie: When a user does not log off from the application and the session state time-out occurs, the application may still use the same session state cookie if the browser is not closed. This behavior causes the user to be directed to the logon page and the session state cookie of the user to be presented. To guarantee that a new session ID is used when you open the logon page (login.aspx), send a null cookie back to the client. To do this, add a cookie to the response collection. Then, send the response collection back to the client. The easiest way to send a null cookie is by using theResponse.Redirectวิธีการ Because the cookies collection always has a value for the ASP.NET_SessionId, you cannot just test if this cookie exists because you will create aResponse.RedirectLoop You can set a query string on the redirect to the logon page. Or, as illustrated in the following code example, you can use a different cookie to tell if you are already redirected to the logon page. To help enhance security and to make sure that no one tries to open the logon page by using a second cookie together with the ASP.NET cookie, the following code example uses theFormsAuthenticationclass to encrypt and decrypt the cookie data. Then, the code example sets a 5-second time-out. คุณสมบัติหมายเลขบทความ (Article ID): 899918 - รีวิวครั้งสุดท้าย: 15 มกราคม 2554 - Revision: 3.0
แปลโดยคอมพิวเตอร์ ข้อมูลสำคัญ: บทความนี้แปลโดยซอฟต์แวร์การแปลด้วยคอมพิวเตอร์ของ Microsoft แทนที่จะเป็นนักแปลที่เป็นบุคคล Microsoft มีบทความที่แปลโดยนักแปลและบทความที่แปลด้วยคอมพิวเตอร์ เพื่อให้คุณสามารถเข้าถึงบทความทั้งหมดในฐานความรู้ของเรา ในภาษาของคุณเอง อย่างไรก็ตาม บทความที่แปลด้วยคอมพิวเตอร์นั้นอาจมีข้อบกพร่อง โดยอาจมีข้อผิดพลาดในคำศัพท์ รูปแบบการใช้ภาษาและไวยากรณ์ เช่นเดียวกับกรณีที่ชาวต่างชาติพูดผิดเมื่อพูดภาษาของคุณ Microsoft ไม่มีส่วนรับผิดชอบต่อความคลาดเคลื่อน ความผิดพลาดหรือความเสียหายที่เกิดจากการแปลเนื้อหาผิดพลาด หรือการใช้บทแปลของลูกค้า และ Microsoft มีการปรับปรุงซอฟต์แวร์การแปลด้วยคอมพิวเตอร์อยู่เป็นประจำ ต่อไปนี้เป็นฉบับภาษาอังกฤษของบทความนี้:899918
(http://support.microsoft.com/kb/899918/en-us/
)
| การแปลบทความ |




กลับไปด้านบน








