O
Owen
I have a web app that is a mixture of ASP and ASP.NET pages. Largely the
only data passed between them is via the querystring, or by reading from a
database. However there is a requirement for one part to communicate via a
cookie. (Please dont ask me to go into why, I don't have time).
In my ASP page, I created a cookie and put a value in it:
Response.Cookies("MyCookieName") = "OriginalValue"
Response.Cookies("MyCookieName").Expires = CDate("31/12/2030")
Response.Cookies("MyCookieName").Path = "/"
That works great. The cookie appears in the Temporary Files folder on disk,
with the distant expiry date as expected. Furthermore I look inside the
cookie using Notepad, and it shows the "OriginalValue" that I put in.
Now I want to read that same cookie from my ASP.NET page, using:
Dim CookieVal as String = Request.Cookies.Item("MyCookieName").Value
....which seems to work perfectly OK. It returns "OriginalValue" that I put
in there using ASP.
Now, the problem is that I cannot seem to *update* the cookie via my ASP.NET
page:
Dim c As HttpCookie = Request.Cookies.Item("MyCookieName")
c.Value = "MyNewValue"
After running the above code, I take a look inside the cookie, but the
"OriginalValue" remains. No errors occurred, it did not crash, but didn't
work either. I cannot understand why.
What am I missing?
Thanks
Owen
PS. replies cc'd via email appreciated as this is quite urgent
(e-mail address removed)
only data passed between them is via the querystring, or by reading from a
database. However there is a requirement for one part to communicate via a
cookie. (Please dont ask me to go into why, I don't have time).
In my ASP page, I created a cookie and put a value in it:
Response.Cookies("MyCookieName") = "OriginalValue"
Response.Cookies("MyCookieName").Expires = CDate("31/12/2030")
Response.Cookies("MyCookieName").Path = "/"
That works great. The cookie appears in the Temporary Files folder on disk,
with the distant expiry date as expected. Furthermore I look inside the
cookie using Notepad, and it shows the "OriginalValue" that I put in.
Now I want to read that same cookie from my ASP.NET page, using:
Dim CookieVal as String = Request.Cookies.Item("MyCookieName").Value
....which seems to work perfectly OK. It returns "OriginalValue" that I put
in there using ASP.
Now, the problem is that I cannot seem to *update* the cookie via my ASP.NET
page:
Dim c As HttpCookie = Request.Cookies.Item("MyCookieName")
c.Value = "MyNewValue"
After running the above code, I take a look inside the cookie, but the
"OriginalValue" remains. No errors occurred, it did not crash, but didn't
work either. I cannot understand why.
What am I missing?
Thanks
Owen
PS. replies cc'd via email appreciated as this is quite urgent
(e-mail address removed)