JavaScript is required

Cho đoạn lệnh sau, xác định chức năng của đoạn lệnh? sub Page_Load(obj as object, e as eventArgs) dim strVariable as string

'set up some cookie variables Response.Cookies("MyASPNETPage")("Username") = "Sinhvien" Response.Cookies("MyASPNETPage")("Password") = "TakeMeHome" Response.Cookies("MyASPNETPage")("Preference") = "800x640" Response.Cookies("MyASPNETPage")("UserAgent") = _ Request.ServerVariables("HTTP_USER_AGENT") for each strVariable in Response.Cookies("MyASPNETPage").Values lblCookies.Text += "" & strVariable & ": " & _ Request.Cookies("MyASPNETPage")(strVariable) & "
"

next end sub

A.

A.Dùng Respone để lưu trữ 1 số thông tin

B.

B.Dùng Request để lưu trữ 1 số thông tin

C.

C.Dùng Variables để lưu trữ 1 số thông tin

D.

D.Dùng Cookies để lưu trữ 1 số thông tin

Trả lời:

Đáp án đúng: D


Đoạn code sử dụng đối tượng `Response.Cookies` để thiết lập (lưu trữ) các cookie trên trình duyệt của người dùng. Cụ thể, nó tạo một cookie có tên "MyASPNETPage" và lưu trữ các thông tin như Username, Password, Preference và UserAgent vào cookie này. Sau đó, nó sử dụng vòng lặp `for each` để duyệt qua các giá trị trong cookie và hiển thị chúng lên Label có tên `lblCookies`. Như vậy, chức năng chính của đoạn lệnh là sử dụng Cookies để lưu trữ thông tin.

Câu hỏi liên quan