简体   繁体   English

我希望用户能够下载页面

[英]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? 在asp.net C#中下载aspx页面。但是它只显示html标记和静态值...如何保存整个页面而不包含html标记和从数据库中检索到的值?
Thanks... 谢谢...
Leema 李玛

Use WebClient for this. 为此使用WebClient 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. 如果我理解正确,那么一种选择是例如使用WebClient实际向Web服务器发出请求。 And then write the response to that request to the Response.OutputStream . 然后将对该请求的响应写入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. 这样,您将让Web服务器实际处理请求并将返回的HTML返回给您,而不只是原始的aspx页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我有一个C#Windows窗体应用程序,希望用户能够安排重复任务 - I have a C# Windows Forms Application and I want the user to be able to schedule a recurring task 我希望我的代码能够显示 3 个选项,如果登录是由 adm1 进行的,并且如果登录是由任何其他用户进行的,我希望可以看到提款/存款 - i want my code to be able to display 3 options if the log in is by adm1 and if the log in is by any other user i want the withdraw/deposit to be seen 我希望有一个页面可以从用户那里收集信息,并且我想获取这些信息并在其他页面和类上使用它 - I want to have a page that collects information from the user, and i want to take that information and use it on other pages and classes 使用 C# 和 Blazor .... 我希望能够确定用户选择了什么 - Using C# and Blazor.... I want to be able to determine what the user selected 当我从页面访问用户控件时,无法从用户控件中的数据库中查看控件的值 - not able to see the controls values from DB in user control when i am access the user control from page 我想下载我在用户系统上使用 XmlWriter.Create() 创建的 C# 中的 XML 文件 - I want to download XML file in C# which I created using XmlWriter.Create() on user's system 我希望能够在网页的代码隐藏中绘制线条 - I want to be able to draw lines in codebehind for webpage 我希望能够通过代码保持控制 - I want to be able to hold down control by code 如何使网页上生成的文件可供用户下载? - How can I make a file generated on a web page available to the user as a download? 我想停靠用户控制 - i want to dock User Control
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM