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!
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.Streamimplementation 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.