• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 394
  • Last Modified:

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>


0
mmaslar
Asked:
mmaslar
  • 4
  • 2
1 Solution
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now