Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

returning the results of a processed aspx page to a string

In normal asp microsoft included a sever object that allowed you to pass in
an asp filename and a local filename and it would process the asp saving the
resulting HTML output to the local file. The primary function for this was
to be able to create static html pages from a database for speed reasons.
(the .htm pages loaded much quicker than the .asp pages and could be cached)

I'm looking for the capability to process an asp page and return the
resulting HTML to a string. Surely with all the foresight in the object
library for NWGS there must exists something like that. Has anyone found
anything like this or knows of an old-school way of doing it?

basically I would want a function to go something like this:

string s = ProcessASPXPage("mypage.aspx?id=10035");

Where the string 's' would contain the static HTML that would be created if
someone where to view the page through a browser. One obvious application
for this is the sending of the HTML in an e-mail (which is what I'm trying
to accomplish) This would be extremely useful and I am inclined to believe
that there has got to be an easy and efficient method of doing this.. if not
there should be!

Thanks!
[1284 byte] By [Thomas Kadlec] at [2007-11-9 18:22:19]
# 1 Re: returning the results of a processed aspx page to a string
Hi Thomas,
Here is a code:

using System;
using System.Net;
using System.IO;

class ASPReader {
static void Main() {
WebRequest req =
WebRequestFactory.Create("http://www.msdn.microsoft.com/net/");
WebResponse res = req.GetResponse();
StreamReader reader = new StreamReader(res.GetResponseStream());
String s = reader.ReadToEnd();
Console.Write(s);
}
}

Don't forget to include option /r:system.web.dll;system.io.dll when
compiling...

Thanks for interesting problem,
Vladimir Suponitsky.

P.S. I am not sure which method(s) of Server object you reffered. Generally
speaking, in ASP+ is there Server object too, which is a global instance of
HttpServerUtility class. So, you can find some info in NGWS SDK
Documentation.

"Thomas Kadlec" <kadlect@hotmail.com> wrote in message
news:39d11a1f@news.dev-archive.com...
> In normal asp microsoft included a sever object that allowed you to pass
in
> an asp filename and a local filename and it would process the asp saving
the
> resulting HTML output to the local file. The primary function for this
was
> to be able to create static html pages from a database for speed reasons.
> (the .htm pages loaded much quicker than the .asp pages and could be
cached)
>
> I'm looking for the capability to process an asp page and return the
> resulting HTML to a string. Surely with all the foresight in the object
> library for NWGS there must exists something like that. Has anyone found
> anything like this or knows of an old-school way of doing it?
>
> basically I would want a function to go something like this:
>
> string s = ProcessASPXPage("mypage.aspx?id=10035");
>
> Where the string 's' would contain the static HTML that would be created
if
> someone where to view the page through a browser. One obvious application
> for this is the sending of the HTML in an e-mail (which is what I'm trying
> to accomplish) This would be extremely useful and I am inclined to believe
> that there has got to be an easy and efficient method of doing this.. if
not
> there should be!
>
> Thanks!
>
>
Vladimir Suponitsky at 2007-11-11 22:27:57 >
# 2 Re: returning the results of a processed aspx page to a string
Can you descripe more detailed what exactly you want to print:
HTML (source) code of your page or browser representation of this code, i.e.
as user see it in IE?
Shortly, code or document?

Best regards,
Vladimir Suponitsky.

> "Thomas Kadlec" <kadlect@hotmail.com> wrote in message
> news:39d11a1f@news.dev-archive.com...

>Excellent! thank you...

>:-)

>You wouldn't happen to also know a way to print an apsx page would >you?
>That would solve the final problem in the c# / asp+ application I am
>developing.
>
>Currently I am using an old asp page that calls a VB com object I wrote >to
>use word automation to open up an instance of word and insert text at
>different book mark locations withing a word template file then I print
>that..

>Unfortunetly, in this case I have many templates and I have to maintain
>both
>an HTML version and WORD version so that people may view them in >their
>browser as well as have us print a hard copy to a laserprinter it would be
>wonderful if I could have my webserver C# / asp+ code print out hard
>copies
>of processed HTML pages.
>
>
>Thanks again for your code example!
>
>Thomas Kadlec

"Vladimir Suponitsky" <suponvla@bellatlantic.net> wrote in message
news:39d14074$1@news.dev-archive.com...
> Hi Thomas,
> Here is a code:
>
> using System;
> using System.Net;
> using System.IO;
>
> class ASPReader {
> static void Main() {
> WebRequest req =
> WebRequestFactory.Create("http://www.msdn.microsoft.com/net/");
> WebResponse res = req.GetResponse();
> StreamReader reader = new StreamReader(res.GetResponseStream());
> String s = reader.ReadToEnd();
> Console.Write(s);
> }
> }
>
> Don't forget to include option /r:system.web.dll;system.io.dll when
> compiling...
>
> Thanks for interesting problem,
> Vladimir Suponitsky.
>
> P.S. I am not sure which method(s) of Server object you reffered.
Generally
> speaking, in ASP+ is there Server object too, which is a global instance
of
> HttpServerUtility class. So, you can find some info in NGWS SDK
> Documentation.
>
>
>
> "Thomas Kadlec" <kadlect@hotmail.com> wrote in message
> news:39d11a1f@news.dev-archive.com...
> > In normal asp microsoft included a sever object that allowed you to pass
> in
> > an asp filename and a local filename and it would process the asp saving
> the
> > resulting HTML output to the local file. The primary function for this
> was
> > to be able to create static html pages from a database for speed
reasons.
> > (the .htm pages loaded much quicker than the .asp pages and could be
> cached)
> >
> > I'm looking for the capability to process an asp page and return the
> > resulting HTML to a string. Surely with all the foresight in the object
> > library for NWGS there must exists something like that. Has anyone found
> > anything like this or knows of an old-school way of doing it?
> >
> > basically I would want a function to go something like this:
> >
> > string s = ProcessASPXPage("mypage.aspx?id=10035");
> >
> > Where the string 's' would contain the static HTML that would be created
> if
> > someone where to view the page through a browser. One obvious
application
> > for this is the sending of the HTML in an e-mail (which is what I'm
trying
> > to accomplish) This would be extremely useful and I am inclined to
believe
> > that there has got to be an easy and efficient method of doing this.. if
> not
> > there should be!
> >
> > Thanks!
> >
> >
>
>
Vladimir Suponitsky at 2007-11-11 22:28:57 >
# 3 Re: returning the results of a processed aspx page to a string
I would like it to print out in as it would appear in a browswer.

For example: say a customer places an order via asp+ pages. I would like a
'work order' sheet to print out on a laser printer that is attatched to the
web server. (This would be used by the workers in the back of the store to
know what items to box up and ship to the customer)

It would be great to have a function like this:

PrintASPPage("http://www.msdn.microsoft.com/net/");

And have a browswer representation print out on the servers default printer.

Say I had written a page called workorder.aspx that would take 'orderid' as
a querystring parameter. In my code I write something like this:

PrintASPPage(http://localhost/workorder.aspx?orderid=20034)

And viola, a sheet would be printed out for that work order.

I've tossed around the idea of using the WebBrowser ActiveX control but
didn't know if
perhaps there was a simpler more efficient way that was more integrated to
NGWS/C#/ASP+

Even printing anything (plain text etc) is something I would be interested
in learning.. as long as it would be provided by NGWS. Currently I am using
word automation and would like to have my own functions to generate
reports.. (ideally it would be printed output from a processed aspx page)
I'm using Microsoft Word as my print engine and I'm sure that cost a lot of
overhead. I'm betting, just like with everything else I've seen so far that
NGWS provides some sort of solution.

Thanks Again!
Thomas Kadlec
Thomas Kadlec at 2007-11-11 22:29:55 >