I'd like to know how VB.NET handles cookies

Falanga, Rod, DOH 245 Reputation points
2025-06-04T21:29:07.1866667+00:00

I maintain an old VB.NET WebForms app. I'm converting it to C# and updating it. However, when it comes to converting how the old app handled browser cookies and how to make the same thing work in a C# Blazor app, I am not sure how to proceed. Here's a snippet that illustrates what I mean. It sets two subparts and assigns an expiration date:

Protected Sub StoreStaffInfoInCookie()
    Response.Cookies("StaffInfoCookie")("ClinicID") = ddlClinic.SelectedValue
    Response.Cookies("StaffInfoCookie")("JobID") = ddlJob.SelectedValue
    Response.Cookies("StaffInfoCookie").Expires = DateTime.Now.AddDays(366)
End Sub

The way I think of it is it is an array. At least that's the way VB.NET is handling here. However, in the Blazor/C# code it looks to me like it separates "StaffInfoCookie" from "ClinicID" using a semicolon. Under the hood, is that what VB.NET is doing?

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,892 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.