Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, November 26, 2024 
 
slxdeveloper.com Community Forums  
   
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!
 Web Forums - ASP/ASP.NET/Web Services/Other
Forum to discuss building external web applications for SalesLogix. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to ASP/ASP.NET/Web Services/Other | New ThreadView:  Search:  
 Author  Thread: ASP.Net cookie slash array issue
David Nunnally
Posts: 206
 
ASP.Net cookie slash array issueYour last visit to this thread was on 1/1/1970 12:00:00 AM
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
[Reply][Quote]
David Nunnally
Posts: 206
 
Re: ASP.Net cookie slash array issueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Jul 06 10:11 AM
fiogf49gjkf0d
Duh! Nevermind!

Must be hung over froim the fourth. Or just brain dead.

Dim cookietxt As String = " " + Context.Request.ServerVariables("HTTP_COOKIE")
Dim cookieArray() = cookietxt.Split(";")

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: ASP.Net cookie slash array issueYour last visit to this thread was on 1/1/1970 12:00:00 AM
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?
[Reply][Quote]
David Nunnally
Posts: 206
 
Re: ASP.Net cookie slash array issueYour last visit to this thread was on 1/1/1970 12:00:00 AM
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!
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/26/2024 4:14:58 AM