仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 608|回复: 7
打印 上一主题 下一主题

[学习教程] ASP.NET教程之Asp.net天生htm静态文件的两种路子

[复制链接]
小女巫 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:49:57 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
数据库有很多应用领域,但是如果你单单学数据库的话基本上做数据库管理员比较合适而已,跟领域结合的你还得再学习那些领域知识。(其实数据挖掘我真是不懂,本来这学期开了一门课了。asp.net|静态//51aspx.com天生静态页演示文件,转载请保存该信息
2publicpartialclass_Default:System.Web.UI.Page
3...{
4protectedvoidPage_Load(objectsender,EventArgse)
5...{
6
7}
8
9//依据模板天生,坚持在html文件夹中(部分源码汇集于收集)
10protectedvoidButton1_Click(objectsender,EventArgse)
11...{
12//源码是交换失落模板中的特性字符
13
14stringmbPath=Server.MapPath("template.htm");
15Encodingcode=Encoding.GetEncoding("gb2312");
16StreamReadersr=null;
17StreamWritersw=null;
18stringstr=null;
19
20//读取
21try
22...{
23sr=newStreamReader(mbPath,code);
24str=sr.ReadToEnd();
25
26}
27catch(Exceptionex)
28...{
29throwex;
30}
31finally
32...{
33sr.Close();
34}
35
36//依据工夫主动重定名,扩大名也能够自行修正
37stringfileName=DateTime.Now.ToString("yyyyMMddHHmmss")+".htm";
38str=str.Replace("$title$",txtTitle.Text);//交换Title
39str=str.Replace("$content$",txtContent.Text);//交换content
40
41//天生静态文件
42try
43...{
44sw=newStreamWriter(Server.MapPath("htm/")+fileName,false,code);
45sw.Write(str);
46sw.Flush();
47
48}
49catch(Exceptionex)
50...{
51throwex;
52}
53finally
54...{
55sw.Close();
56Response.Write("祝贺<ahref=htm/"+fileName+"target=_blank>"+fileName+"</a>已天生,保留在htm文件夹下!");
57}
58
59
60}
61
62
63//依据Url地点天生静态页坚持
64protectedvoidButton2_Click(objectsender,EventArgse)
65...{
66Encodingcode=Encoding.GetEncoding("utf-8");
67StreamReadersr=null;
68StreamWritersw=null;
69stringstr=null;
70
71//读取远程路径
72WebRequesttemp=WebRequest.Create(txtUrl.Text.Trim());
73WebResponsemyTemp=temp.GetResponse();
74sr=newStreamReader(myTemp.GetResponseStream(),code);
75//读取
76try
77...{
78sr=newStreamReader(myTemp.GetResponseStream(),code);
79str=sr.ReadToEnd();
80
81}
82catch(Exceptionex)
83...{
84throwex;
85}
86finally
87...{
88sr.Close();
89}
90stringfileName=DateTime.Now.ToString("yyyyMMddHHmmss")+".htm";
91
92//写进
93try
94...{
95sw=newStreamWriter(Server.MapPath("htm/")+fileName,false,code);
96sw.Write(str);
97sw.Flush();
98
99}
100catch(Exceptionex)
101...{
102throwex;
103}
104finally
105...{
106sw.Close();
107Response.Write("祝贺<ahref=htm/"+fileName+"target=_blank>"+fileName+"</a>已天生,保留在htm文件夹下!");
108}
109
110}
111}呵呵,那你就关注微软的招聘信息以及别人的招聘经验啊,还有也不一定去做技术的,你如果真的想去就多了解了解。(其实我的意思是说想到微软做技术是很不容易的。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-6-17 23:21

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表