System.NullReferenceException w/ IFRAME

This URL works fine all the time: http://www.poweredbyblackpants.com/Register.aspx?CampaignID=32

But when displaying that page within an IFRAME on another web site, there's a good chance that it'll generate a NullReference error. Sometimes it works... many times not: http://www.blackpants.com/demo/RegisterDemo.html

RegisterDemo.html source:
<HTML><HEAD>
<TITLE>Registration demo page</TITLE>

<link rel="stylesheet" href="RegisterDemo.css" type="text/css">
</HEAD>

<body bgcolor="#FFFFFF">
<DIV
STYLE="position:absolute;
       left:103px;
       top:127px;
       width:650px;
       height:950px;
       border: 1px none #000000; background-color: #FFFFFF; layer-background-color: #FFFFFF"
> <IFRAME
SRC="http://www.poweredbyblackpants.com/Register.aspx?CampaignID=32"
WIDTH="650"
HEIGHT="950"
MARGINWIDTH=0
MARGINHEIGHT=0
FRAMEBORDER="NO"
SCROLLING="NO"
STYLE="border-width:0;
       border-color:#FFFFFF;
       border-style:solid;"
> Sorry, your browser does not support inline frames. </IFRAME> </DIV>



<img src="../images/logo2.gif" width="180" height="107">
</BODY></HTML>


mmaslarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

der_jthCommented:
IFRAMEing itself has nothing to do with nullreferenceexceptions. The error is generic enough to be nigh-undebuggable; I suggest you turn on debug mode on the server. That way you can get a stack trace / source excerpt for the error and pinpoint the source of the exception at least on a method level.
0
mmaslarAuthor Commented:
> turn on debug mode on the server

On the server, Web.config is already set to <compilation defaultLanguage="c#" debug="true" />. Is that what you mean?

This is what I get back:
Server Error in '/' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   EventRegistration.EventRegistration_SelectionReview.Page_Load(Object sender, EventArgs e) +385
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Page.ProcessRequestMain() +750

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032



Regards,
Mark
0
mmaslarAuthor Commented:
Could this be the reason...

The server that has the HTML page w/ IFRAME does NOT have the .Net framework installed.

Moving the page to a server that does have the framework, and the framed content works as intended: http://www.poweredbyblackpants.com/RegisterDemo.html

My goal in using IFRAME was to embed dynamic content into various web pages, regardless of what type of server being used. Possible?

Mark
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

der_jthCommented:
No, the server that loads the stuff into an IFrame isn't causing the issue. That server doesn't need to parse any .NET code, and even if it had, it certainly wouldn't give out a .NET Framework error message.

Anyway, your stack trace shows:

[NullReferenceException: Object reference not set to an instance of an object.]
   EventRegistration.EventRegistration_SelectionReview.Page_Load(Object sender, EventArgs e) +385
   ...

This indicates that the NullRefEx was raised inside that particular method. If you compile the DLL in debug mode and copy both the .DLL and the .PDB file into the web server's bin directory, you can also get the line number in the source code where the problem occurred. Could you do that? If not, paste the whole Page_Load method here and let's see.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mmaslarAuthor Commented:
> copy both the .DLL and the .PDB file into the web server's bin directory
That shed some light.

What's happening is that the Session variable is disappearing from one page to the next. I've tried setting the cookie's timeout to 30 minutes, but that makes no difference:

DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(0,30,0);
Response.Cookies ["RegistrationSelections"].Expires = dt.Add(ts);
if ((string)Session["RegistrationSelections"] != "") Response.Redirect(Application["this_server"] + "Payment.aspx", true); // redirect to payment page

On the payment page, this line causes: System.NullReferenceException: Object reference not set to an instance of an object.

string test = Session["RegistrationSelections"].ToString();

So... how do I keep the session variable intact?


0
mmaslarAuthor Commented:

> So... how do I keep the session variable intact?

Got it! Removing    Application["this_server"] was the key.

Response.Redirect(Application["this_server"] + "Payment.aspx", true)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.