default.aspx
来自「ASP.NET Web Forms Techniques」· ASPX 代码 · 共 53 行
ASPX
53 行
<%@Page Language="C#" %>
<%@Import Namespace="System.IO" %>
<%@Import Namespace="System.Net" %>
<script runat="server">
void Page_Load() {
// ******** Remember to edit next line to match location of this file ********
// ******** ASPNET account must have write permission for this folder ********
String sOriginalFile = "http://localhost/7868-cs/static-pages/input-page.aspx";
String sDiskFile = "result.htm";
// create a Web Request object with a specified virtual path
WebRequest oWRequ = WebRequest.Create(sOriginalFile);
// send the request and collect the response in a Stream object
WebResponse oWResp = oWRequ.GetResponse();
Stream oStream = oWResp.GetResponseStream();
// create a StreamReader to read the stream
StreamReader oReader = new StreamReader(oStream, Encoding.ASCII);
// create a StreamWriter and use it to write the stream to a disk file
StreamWriter oWriter = new StreamWriter(Server.MapPath(sDiskFile));
oWriter.Write(oReader.ReadToEnd());
// close all the objects
oWriter.Close();
oReader.Close();
oWResp.Close();
// display confirmation that it worked
lblOutput.Text = sOriginalFile;
aLink.Text = sDiskFile;
aLink.NavigateUrl = sDiskFile;
}
//-----------------------------------------
</script>
<html>
<body>
<font face="Arial,sans-serif" size="2"><b>
Used the file:
<asp:Label id="lblOutput" runat="server" />
<br />to generate the file:
<asp:Hyperlink id="aLink" runat="server" />
</b></font>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?