Avatar of SeTech
SeTech
Flag for United States of America asked on

Web app works in Debug mode, not otherwise

I asked a question about this a few months back, and it ended up off on a tangent. However, I'm having the problem again, and I need to get this resolved.

I have a web app (C#, and ASP.Net 2.0 developed using Visual Studio 2005), and in the Global.asax Session_Start event, I am calling a number of methods from a Class Library my unit developed to populate Session variables that are used throughout the app. The app physically resides on a web server, so after compiling/building the site, we access it using IE and the virtual directory that's set up using IIS.

Here's where it gets frustrating. After building the site and trying to access it, I get an error message thrown from Default.aspx's code-behind, in essence saying that a Session variable I populated in Global.asax is null (that's my translation of the error code put in context). So wondering if I messed it up somehow, I put a Debug breakpoint in the Session_Start method in Global.asax and stepped through the whole method, only to see it work perfectly, and the IE window it brought up while debugging displays the page just like it should. But if I just put the virtual address in IE and try to access it normally, I still get the error.

So why can I get the page to work in Debug mode, but not normally?
.NET ProgrammingASP.NETC#

Avatar of undefined
Last Comment
SeTech

8/22/2022 - Mon
ydramu

Hi

When we access the application from the Visual Studio 2005 it makes use the Development web server.

And as you mentioned, the problem occured when you running the application using Virtual Directory, could you make sure once the ASP.NET Configuration for this web application points to .NET Framework 2.x.

This might be already configured properly, but as a first step of reviewing the application for the issue, I am asking this to verify.

Thanks
SeTech

ASKER
Yes, it is configured to use ASP.Net 2.0.something (I forget all the other numbers) in the IIS. And I understand making sure important things aren't overlooked. So what's the next step?
ydramu

what is the value you are trying to get into your session variable?

If it is getting access to any system resources and then getting their values, make sure, if you have right permissions to access those.

One more thing, what is the application authentication mode used?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SeTech

ASKER
There are multiple Session variables, and they are supposed to just hold Strings. The strings are output of methods from the Class Library I mentioned. They don't try to access system resources.

It uses Windows authentication.
ydramu

Can you post the error message what you are getting exactly?
SeTech

ASKER
The error message itself is an "object reference not set to instance of an object" error. The line of code that is causing the exception is one that calls ToString() on a Session variable. Thus, I know it thinks the Session variable is null. Since I can clearly see in the code that I do in fact set the Session variable (double- and triple-checked), AND since it clearly works in Debug mode, I am stumped.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ydramu

This seems your class library not returning the value while running through the IIS Web server. Is that library  prepared by you or any third party component.
SeTech

ASKER
Yes, the class library was written by my unit. I have full control over it.
ydramu

So try to debug through that class library by step into that line of statement which tries to access your Class library to get the value to store into session.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
SeTech

ASKER
I have already done that, and when I debug and step into any line that tries to access the class library, it works fine, with no problems. It only causes a problem when I am trying to access the page normally through IE.
ydramu

Ok, can you try to write the value to a text file in your library, and try to execute the application from Web Server, if your library returns value, it should write the value to the file.

Why because from the web application, it seems fine with all aspects of code as per you mentioned.
SeTech

ASKER
I'm not sure I follow that at all, can you please clarify a bit?

Further, in a completely different web application, we're having a similar issue, this time not even related to Session variables. The same class library is being instantiated to populate variables (this time just in a simple .aspx page). When built and accessed normally, the variables are all null. When run in Debug mode, it populates the variables with no trouble.

I would say the problem must lie with the library, but the exact same library is running in at least a dozen other web apps with no problems whatsoever. So somehow there must be a coding quirk that is causing this to happen. Any thoughts?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
ydramu

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SeTech

ASKER
As far as security and authentication, all the web apps are identical, I checked.
ASKER CERTIFIED SOLUTION
SeTech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.