Leema
Leema

Reputation: 97

I want the user to be able to download a page

I am using the code,

    string loadFile = HttpContext.Current.Request.Url.AbsoluteUri;
    // this.Response.ClearContent();
    // this.Response.ClearHeaders();
    this.Response.AppendHeader("content-disposition", "attachment; filename " + filename);
    this.Response.ContentType ="application/html";

    this.Response.WriteFile("C:\\Users\\Desktop\\Jobspoint Website\\jobpoint3.0\\print.aspx");
    this.Response.Flush();
    this.Response.Close();
    this.Response.End();

to download an aspx page in asp.net C#.. But its only showing the html tags and static values... How can I save the entire page without html tags and with the values that retrieved from the database?
Thanks...
Leema

Upvotes: 1

Views: 101

Answers (2)

Pankaj Mishra
Pankaj Mishra

Reputation: 20358

Use WebClient for this. It will download your file.

Upvotes: 5

Chris Taylor
Chris Taylor

Reputation: 53729

If I have understood correctly, one option would be to actually make a request to the web server using WebClient for example. And then write the response to that request to the Response.OutputStream. This means that the server will actually make a second request to it self and then send the response to the second request back to the client.

This way you will have the web server actually process the request and return the resulting HTML back to you rather than just the raw aspx page.

Upvotes: 4

Related Questions