开发者

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#.. Bu开发者_JAVA百科t 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


Use WebClient for this. It will download your file.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜