views:

105

answers:

2

Here is my scenario. User fills out this large page which is dynamically created based off DB values. Those values can change. When the user fills out the page and hits submit we want to save a copy of the page as html on the server, this way if the text or wording changes, when they go back to view their posted information, it is historically accurate.

So I basically need to do this

protected void buttonSave_Click(object sender, EventArgs e)
{
    //collect information into an object to save it in the db       
    bool result = BusinessLogic.Save(myBusinessObject);

    if (result)
        //!!! Here is where I need to save this page as an html file on my servers IFS!!!!
    else
        //whatever

    Response.Redirect("~/SomeOtherPage.aspx");
}

Any help is greatly apprciated. Also I CANNOT just request the data from the url because query string parameters are a big no no in this case. The key to pull the database info up (at its highest level) is all in session so I cant just request a url and save it.

Thanks!

A: 

You will have to deal with several problems here.

First of all If I understood you correctly you want to intercept the HTML as it is generated. You can do it in a number of ways - i.e. you can write a Filter object - a System.IO.Stream implementation which in addition to passing through the original HTML data stream copies it on the side. Such object can be hooked up to the HttpResponse through its Filter property.

Keep in mind that not all data sent to HttpResponse allow filtering.

Then you will have to deal with another problem: By the time the 'Save' request hits your server your original page is gone. It was sent to the user as a result of the previous request/response round trip, so unless you have a way to re-create your html on the second roundtrip you will have to save it temporarily on the first roundtrip and 'commit' on the second one - when your buttonSave will be executed.

mfeingold
Looks like I am just going to go with saving it via ABCPDF. I liked this answer though and probably some initial testing shows it wouldve been the way to go. Thanks!
chrisjlong
+1  A: 

I think in "else case" you can call a HTMLSnap kind of control which will get the snap shot of the URL as a image. But this will not have the user entered values though. It will have snapshot of page when it loads.

http://www.guangmingsoft.net/htmlsnapshot/help.htm

As other users mentioned u cannot get the with user entered values since HTML page have all other resource as well which is diffcult to get at server side.

If u are not interestred on User entered content above mentioned approach might work.