Re: ASP.Net Page that has a control to display HTML

From: David Elliott (DavidElliott_at_BellSouth.net.nospam)
Date: 03/02/04


Date: Tue, 02 Mar 2004 08:14:11 -0500

I got it.

It turns out that loading the page into my application was fine. The problem was that
the page was loading a cookie to automatically log me into my Yahoo account. It was
then posting back to my ASPX page to display which is what the r0=.... number is below.
Once I logged out of Yahoo the page displayed successfully.

I still don't know about using End().

Thanks all for the help.

Cheers,
Dave

On Mon, 01 Mar 2004 09:07:47 -0500, David Elliott <DavidElliott@BellSouth.net.nospam> wrote:

>I changed from Close() to End() as suggested and it throws an exception:
> ex.Message "Thread was being aborted.". I was using a simple hard coded
>string " <html><body><h1>This is some text</h1></body></html>"
>
>The failure to display the HTML, I believe it has something to do with the data
>contained inside of the HTML file. If I create a file using the string above, the
>output is displayed correctly. Upon viewing the source, it is identical to the
>file on disk. No additional headers or information.
>
>The data file I had been using for testing purposes was the Yahoo.com main page.
>I just saved it to disk and then read it into a byte[] (see previous message below)
>and then do the write. Using this yahoo.htm file instead of the simple html file, I get
>nothing displayed. When I view the source code, the following is displayed which
>doesn't look like the Yahoo.com file on disk..
>
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
><HTML>
><HEAD>
><title>ImageFeed</title>
><meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
><meta name="CODE_LANGUAGE" Content="C#">
><meta name="vs_defaultClientScript" content="JavaScript">
><meta name="vs_targetSchema"
>content="http://schemas.microsoft.com/intellisense/ie5">
></HEAD>
><body MS_POSITIONING="GridLayout">
><form name="Form1" method="post" action="ImageFeed.aspx?r0=1077912660"
>id="Form1">
><input type="hidden" name="__VIEWSTATE"
>value="dDwtMTI3OTMzNDM4NDs7Ppf+ZVIuJLGxTqy+PZFowk7vf36y" />
>
></form>
></body>
></HTML>
>
>
>
>Cheers,
>Dave
>
>
>
>On Fri, 27 Feb 2004 21:27:09 +0100, "Martin Dechev" <decheff_@hotmail.com> wrote:
>
>>Hi, David Elliott,
>>
>>Are you sure that you are not viewing a cached version of the page? Delete
>>your temp. files in the IE. If you are running Windows Server (IIS 6.0) you
>>might need to restart the w3svc service because there is some bizzare
>>caching which is not documented but many people are experiencing it.
>>
>>Also, call Response.End() instead of Response.Close()
>>
>>Greetings
>>Martin
>>"David Elliott" <DavidElliott@BellSouth.net.nospam> wrote in message
>>news:pf8v301mj3iclfathlolhelrg7g9nvibuu@4ax.com...
>>>
>>> I added <iframe id=extText runat=server></iframe> to my ASPX page and
>>defined
>>> protected System.Web.UI.HtmlControls.HtmlGenericControl extText;
>>>
>>> htmlString = @"ImageFeed.aspx?docId=" + docID;
>>> extText.Attributes["src"] = htmlString;
>>>
>>> If I have ImageFeed defined to return:
>>> dataString = @"<html><body><h1>hello world 12</h1></body></html>";
>>> Response.Write(dataString);
>>> Response.Flush();
>>> Response.Close();
>>>
>>> Everything works fine.
>>>
>>> =======================
>>>
>>> If I cache a file
>>> FileStream fs = new FileStream(filename, FileMode.Open);
>>> byte[] data = new byte [fs.Length];
>>> fs.Read(data, 0, (int)fs.Length);
>>> fs.Close();
>>>
>>> and have ImageFeed defined to return
>>> data = (byte[])document;
>>> string dataString = Encoding.UTF8.GetString(data);
>>>
>>> Response.Write(dataString);
>>> Response.Flush();
>>> Response.Close();
>>>
>>> This doesn't work. Using the debugger, I verified that dataString has the
>>correct information (i.e. the HTML)
>>>
>>> If I view the source it returns some generated text from who knows where.
>>Isn't anything like what I am trying
>>> to load. It looks like this.
>>>
>>>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
>>> <HTML>
>>> <HEAD>
>>> <title>ImageFeed</title>
>>> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
>>> <meta name="CODE_LANGUAGE" Content="C#">
>>> <meta name="vs_defaultClientScript" content="JavaScript">
>>> <meta name="vs_targetSchema"
>>content="http://schemas.microsoft.com/intellisense/ie5">
>>> </HEAD>
>>> <body MS_POSITIONING="GridLayout">
>>> <form name="Form1" method="post" action="ImageFeed.aspx?r0=1077912660"
>>id="Form1">
>>> <input type="hidden" name="__VIEWSTATE"
>>value="dDwtMTI3OTMzNDM4NDs7Ppf+ZVIuJLGxTqy+PZFowk7vf36y" />
>>>
>>> </form>
>>> </body>
>>> </HTML>
>>>
>>>
>>> Any help would be appreciated.
>>>
>>> Thanks,
>>> Dave
>>>
>>>
>>>
>>>
>>>
>>> On Fri, 27 Feb 2004 19:53:18 +0100, "Martin Dechev" <decheff_@hotmail.com>
>>wrote:
>>>
>>> >Hi, David Elliott,
>>> >
>>> >How about an iframe? In the class you can declare it as
>>> >System.Web.UI.HtmlControls.HtmlGenericControl, just don't forget the
>>> >runat="server" attribute in the .aspx. You can set the attributes (src,
>>> >width, height, border, etc) from the property Attributes, i.e.
>>> >iframe1.Attributes["src"] = "somepage.aspx";
>>> >
>>> >Greetings
>>> >Martin
>>> >"David Elliott" <DavidElliott@BellSouth.net.nospam> wrote in message
>>> >news:si1v30511862dba399h2c1b3m9scltepl3@4ax.com...
>>> >> I need a control on a Web Page that can accept an HTML Document and
>>will
>>> >display it.
>>> >>
>>> >> Any help would be appreciated.
>>> >>
>>> >> Thanks,
>>> >> Dave
>>> >>
>>> >>
>>> >> Here is what I was trying...
>>> >>
>>> >>
>>> >> protected System.Web.UI.WebControls.Panel htmlPanel;
>>> >> protected System.Web.UI.WebControls.Image htmlImage;
>>> >>
>>> >>
>>> >> htmlString = @"ImageFeed.aspx?docId=" + docID;
>>> >>
>>> >> htmlPanel.BackImageUrl = htmlString;
>>> >>
>>> >> htmlImage.ImageUrl = htmlString;
>>> >> htmlImage.Visible = true;
>>> >>
>>> >>
>>> >>
>>> >> public class ImageFeed : System.Web.UI.Page
>>> >> {
>>> >> private void Page_Load(object sender, System.EventArgs e)
>>> >> {
>>> >> string htmlData = @"<html><body><h3>Hello World</h3></body></html>";
>>> >> Response.Write(htmlData);
>>> >> }
>>> >> }
>>> >
>>>
>>



Relevant Pages