Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 22, 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: public myvar as string = HttpContext.Current.User.Identity.Name in Module issue
David Nunnally
Posts: 206
 
public myvar as string = HttpContext.Current.User.Identity.Name in Module issueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 May 07 8:54 AM
fiogf49gjkf0d
I have a vb.net 2003 web project with a module. The module has several public functions and subs and public myvar as string = HttpContext.Current.User.Identity.Name. Variable myvar is accessed in multiple web pages. The problem is when the website is started myvar = the first user to access the application. Then every other user after that initial load has myvar = that first user. If I remark that line and add dim myvar as string = HttpContext.Current.User.Identity.Name in every sub that uses myvar then it grabs the current user as intended. What am I doing (or understanding) wrong here?
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: public myvar as string = HttpContext.Current.User.Identity.Name in Module issueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 May 07 5:01 PM
fiogf49gjkf0d
A VB "module", having global context, exists in thread local storage. Because of this, global variables in a VB module is global to the process, regardless of "session". Know what I mean?

A better route is to use a class and put the variable as Shared (equivalent to C#'s "static").
[Reply][Quote]
David Nunnally
Posts: 206
 
Re: public myvar as string = HttpContext.Current.User.Identity.Name in Module issueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 May 07 8:25 AM
fiogf49gjkf0d
Module bad - got it!
I was afraid it had something to do with my use of a module!
But now I learned something new!

Thanks for the insight Ryan.
[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/22/2024 4:53:14 PM