C#, Saving currently loaded aspx page to a file.

Necuno

Court Jester
Joined
Sep 27, 2005
Messages
58,566
Reaction score
3,437
quick Q, how do i either get the document part of the loaded page or just save the thing to file ?

-tx
 
WebRequest myRequest = WebRequest.Create("http://MyApplication/MyPage.aspx");
WebResponse myResponse = myRequest.GetResponse();
Stream ReceiveStream = myResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( ReceiveStream, encode );
Char[] read = new Char[256];
int count = readStream.Read( read, 0, 256 );
using (StreamWriter sw = new StreamWriter("MyPage.htm"))
{
while (count > 0)


{


// Dump the 256 characters on a string and display the string onto the console.


String str = new String(read, 0, count);


sw.Write(str);


count = readStream.Read(read, 0, 256);


}


}
myResponse.Close();


prolly like that and it was the first link in google..
 
i see; will play with tomorrow thanks :)
 
im using this.

Code:
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
mainDiv.RenderControl(w);
string s = sw.GetStringBuilder().ToString();

all the "content" i want is inside the div, which i get as a string and then write that as a file. in short i wanted to render a html form with some values from datasource, save it as excel; then mail it off to be doubled checked.

quickest way i know to built an excel file without doing transformation and so forth anyways.
 
Nasty:P why not just bundle the values in some sort of datagram packet? or does it need to be emailed like some flyer?
 
Nasty:P why not just bundle the values in some sort of datagram packet? or does it need to be emailed like some flyer?

well here is the situation;

We are merging with another company and the hr data (such as gender, address..and so on) needs to be taken from their data source and then be looked through after it has been sent off to each indivitual to double check his/her info. that is why the excel route and why i'm actually rendering a plain html table with all the things in and saving it to .xls
 
well here is the situation;

We are merging with another company and the hr data (such as gender, address..and so on) needs to be taken from their data source and then be looked through after it has been sent off to each indivitual to double check his/her info. that is why the excel route and why i'm actually rendering a plain html table with all the things in and saving it to .xls

Why not just get yourself a decent web-based HR solution?

(RAS? :p)
 
Top
Sign up to the MyBroadband newsletter
X