两种将.aspx转换为.html的方法


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

//根据Url地址生成静态页保持

protected void Button2_Click(object sender, EventArgs e)

{

  Encoding code = Encoding.GetEncoding("utf-8");

            StreamReader sr = null;

            StreamWriter sw = null;

            string str = null;

            //读取远程路径

            WebRequest temp = WebRequest.Create(txtUrl.Text.Trim());

            WebResponse myTemp = temp.GetResponse();

            sr = new StreamReader(myTemp.GetResponseStream(), code);

            //读取

            try

            {

                sr = new StreamReader(myTemp.GetResponseStream(), code);

                str = sr.ReadToEnd();

            }

            catch (Exception ex)

            {

                throw ex;

            }

            finally

            {

                sr.Close();

            }

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".htm";

            //写入

            try

            {

                sw = new StreamWriter(Server.MapPath("htm/") + fileName, false, code);

                sw.Write(str);

                sw.Flush();

            }

            catch (Exception ex)

            {

                throw ex;

            }

            finally

            {

                sw.Close();

                Response.Write("恭喜<a href=htm/" + fileName + " target=_blank>" + fileName + "</a>已经生成,保存在htm文件夹下!");

            }

        }

以上就是两种将.aspx转换为.html的方法的详细内容!

返回前面的内容

相关阅读 >>

使用c#实现发送自定义的html格式邮件的代码案例

完美解决sqldatareader指定转换无效

用asp.net mvc部分视图渲染html的实例教程

分享html元素调用服务器实例

c#中datetime与时间戳转换的实例代码

分享在c#中时间戳是怎么转换的?

c#怎么将 html转换为图片或 pdf?

两种将.aspx转换为.html的方法

c# 清除html标签标记

开发中常遇到的问题--日期格式化转换.

更多相关阅读请进入《aspx》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...