The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
ASP.Net cookie slash array issue
Posted: 05 Jul 06 10:04 AM
|
fiogf49gjkf0d I have the follow script giving me issues. When the cookie is already set it works. But once it expires or on new users it errors on the Dim line. I know I need to do some err checking and handling here but not sure what action to take.
Err is: System.NullReferenceException: Object reference not set to an instance of an object.
Dim cookieArray() = Context.Request.ServerVariables("HTTP_COOKIE").Split(";") If IsArray(cookieArray) Then Dim i As Integer For i = 0 To UBound(cookieArray) Response.Write(" blah blah blah ") Response.Write(Trim(cookieArray(i))) If i < UBound(cookieArray) Then Response.Write(" ") End If Next End If |
|
|
| |
|
Re: ASP.Net cookie slash array issue
Posted: 05 Jul 06 12:23 PM
|
fiogf49gjkf0d Instead of getting the HTTP_COOKIE server var, I would just use the cookies collections. Makes for for easier access to get the specific cookie you're after:
HttpCookie c = Request.Cookies.Get("MyCookieName"); Response.Write(c.Value);
Writing the cookie is just as easy:
HttpCookie c = new HttpCookie("MyCookieName", "The value for my cookie); c.Expires = DateTime.Now.AddYears(10); Response.Cookies.Add(c);
Anyway, glad you got it worked out, but I just wanted to mention that the cookie collection will give you a far easier time than getting the server var and parsing them out. Know what I mean? |
|
|
|
Re: ASP.Net cookie slash array issue
Posted: 06 Jul 06 8:30 AM
|
fiogf49gjkf0d Thanks Ryan, I will try that.
Yeah, I really need to learn .Net. I have been trying to convince my boss to send me to class. More of our apps are going .Net.
In the mean time I will just blindly walk through the maze! |
|
|
|