468,321 Members | 1,824 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

How to use SimpleWorkerRequest?

In my ASPX page i want to output the result of another ASPX page to the
file.
So i wrote following code
private void Page_Load(object sender, System.EventArgs e)

{

StreamWriter sw = new StreamWriter("c:\\TestFile.txt");

SimpleWorkerRequest wr= new SimpleWorkerRequest("General.aspx", "", sw);

HttpRuntime.ProcessRequest(wr);

}

But second line throws an exception

System.NullReferenceException: Object reference not set to an instance of an
object.
I can hit General.aspx with the browser and it works without any problem.

Thanks.
George.
Nov 17 '05 #1
3 6304
You can use the WebRequest object to call your web page, then you can
capture the HTML that it output.

Here's a nice example:
http://www.digitalvideotoolbox.com/M...on.aspx?QID=88

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
--------------------------------
Hire top notch developers to get your projects done right:
http://www.able-consulting.com
--------------------------------

"George Ter-Saakov" <we@hotmail.com> wrote in message
news:uj**************@tk2msftngp13.phx.gbl...
In my ASPX page i want to output the result of another ASPX page to the
file.
So i wrote following code
private void Page_Load(object sender, System.EventArgs e)

{

StreamWriter sw = new StreamWriter("c:\\TestFile.txt");

SimpleWorkerRequest wr= new SimpleWorkerRequest("General.aspx", "", sw);
HttpRuntime.ProcessRequest(wr);

}

But second line throws an exception

System.NullReferenceException: Object reference not set to an instance of an object.
I can hit General.aspx with the browser and it works without any problem.

Thanks.
George.

Nov 17 '05 #2
Thit is not what i want.

I want to run ASPX page inside of my WebApplication (so session will be the
same ) and capture the HTML.
George.
"Steve C. Orr, MCSD" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You can use the WebRequest object to call your web page, then you can
capture the HTML that it output.

Here's a nice example:
http://www.digitalvideotoolbox.com/M...on.aspx?QID=88

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
--------------------------------
Hire top notch developers to get your projects done right:
http://www.able-consulting.com
--------------------------------

"George Ter-Saakov" <we@hotmail.com> wrote in message
news:uj**************@tk2msftngp13.phx.gbl...
In my ASPX page i want to output the result of another ASPX page to the
file.
So i wrote following code
private void Page_Load(object sender, System.EventArgs e)

{

StreamWriter sw = new StreamWriter("c:\\TestFile.txt");

SimpleWorkerRequest wr= new SimpleWorkerRequest("General.aspx", "", sw);

HttpRuntime.ProcessRequest(wr);

}

But second line throws an exception

System.NullReferenceException: Object reference not set to an instance of an
object.
I can hit General.aspx with the browser and it works without any

problem.
Thanks.
George.


Nov 17 '05 #3
That's a very strange thing to do.
Is this page being displayed to the user?
If so, you should be able to override the Render method of your page object
and get a copy of the final output from there.
The HtmlTextWriter parameter should hold the output.

Here's more info:
http://msdn.microsoft.com/library/de...endertopic.asp

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
--------------------------------
Hire top notch developers to get your projects done right:
http://www.able-consulting.com
--------------------------------

"George Ter-Saakov" <we@hotmail.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
Thit is not what i want.

I want to run ASPX page inside of my WebApplication (so session will be the same ) and capture the HTML.
George.
"Steve C. Orr, MCSD" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You can use the WebRequest object to call your web page, then you can
capture the HTML that it output.

Here's a nice example:
http://www.digitalvideotoolbox.com/M...on.aspx?QID=88

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
--------------------------------
Hire top notch developers to get your projects done right:
http://www.able-consulting.com
--------------------------------

"George Ter-Saakov" <we@hotmail.com> wrote in message
news:uj**************@tk2msftngp13.phx.gbl...
In my ASPX page i want to output the result of another ASPX page to the file.
So i wrote following code
private void Page_Load(object sender, System.EventArgs e)

{

StreamWriter sw = new StreamWriter("c:\\TestFile.txt");

SimpleWorkerRequest wr= new SimpleWorkerRequest("General.aspx",
"", sw);

HttpRuntime.ProcessRequest(wr);

}

But second line throws an exception

System.NullReferenceException: Object reference not set to an instance

of
an
object.
I can hit General.aspx with the browser and it works without any

problem.
Thanks.
George.



Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by sureshsundar007 | last post: by
7 posts views Thread by sureshsundar007 | last post: by
reply views Thread by clécio | last post: by
3 posts views Thread by Seth | last post: by
5 posts views Thread by Brian Takita | last post: by
reply views Thread by Kevin Baribeau | last post: by
11 posts views Thread by Mark Carrington | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.