We help IT Professionals succeed at work.
Get Started

Do I need session variables?  Scoping? Extend code behind pages

SamCash
SamCash asked
on
281 Views
Last Modified: 2015-03-30
I just learned about session variables from another issue.  Saw the potential problem with "static variable" with multiple people browsing my site.  I do not know if my structure causes an instance of BLogic for each pages code behind and I am OK, or if I have been lucky due to only two developers using the site.  How would one test something like this?  Am I safe?

I have 3 layers
1) forms webpage

2) code behind // for web developers, format, controls, etc., minor logic
----using WebApplication1.BusinessLogic;
----namespace WebApplication1.Debug
----public partial class Concantonate : System.Web.UI.Page

----protected void btnFormat_Click(object sender, EventArgs e)
----lblResultStringEmailPhoneNumber.Text = BLogic.FormatEmailPhoneNumber(ContactEmail, PhoneNumber);

3) BusinessLogic //all major logic, business flow etc
----namespace WebApplication1.BusinessLogic
----public class BLogic
----public static string UniqueMessage;
----public static string  FormatEmailPhoneNumber(ContactEmail, PhoneNumber)
     {

Thanks
Sam

Update:

I saw a lot of redundant code that the web developers were copy/paste to many code behind pages, they are already having trouble when a bug or change is made, hours of doing the exact change to many items.  To reduce this I made another c# code page where I am putting all the redundant code, one place to update or fix bug.  One potential problem is multiple users (above) and the second difficult access to session variables (so I am passing parameters in function calls) , everything seems to be working.  I believe there is a way to extend, inherit, or somehow hook to the code behind pages, maybe I should instantiate an instance of the BLogic in each code behind page.  Sorry my question may not be very clear but I hope I have communicate the objective, how is the correct ay to do this.

Thanks Again
Sam
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE