asp网页源码,asp动态网页源码
大家好,今天给各位分享asp网页源码的一些知识,其中也会对asp动态网页源码进行解释,文章篇幅可能偏长,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在就马上开始吧!
asp网站源代码
在局域网里搭建一个web服务器,固定该机的内网IP,要win2003系统,XP的不行,因为IIS连接数有限制,搭建好,把程序放上去,其他电脑直接输入这台服务器的IP地址就可以访问了。
如果要外网登陆,要先把局域网的路由器映射到这台服务器上,一般是在路由器里设置DMZ主机,然后填上服务器的内网IP。
外网访问时是要输入外网的IP,可以上IP138查询到。
如果你们宽带是固定IP的话申请个域名指向这个IP就行了,如果不是固定IP,就需要使用动态域名,现在常用的是“花生壳”
怎么下载网上的单个asp页面源代码
楼上错了,网际快车是可以下,但下的根本就不是源代码,而是在服务器端执行后发送到客户端的代码.网上有一些工具是可以偷取网站的源码的,楼主可以自己去搜.
在这告诉楼主一个区分下到的文件是不是真正的ASP源码的方法:
看文件中有没有"<%"和"%>"(引号中的部分),如果有则是源码,没有则是已经在服务器端执行过的,是没有用的
急急急求两个ASP动态网页代码
1)asp生成html的方式
要生成文件肯空要用到FSO(FileSystemObject)组件,通过asp生成静态网页主要有两种方式:
a、生成的内容由多部分连接而成;
b、生成的内容基于模板生成。
2)方式1:生成的内容由多部分连接而成
步骤:
a、设计要输出网页的布局
b、设计生成HTML的asp文件
例子:
输出网页的布局:
<html>
<head>
<title>标题</title>
<style type="text/css">
<!--
.article_title{
font-size: 22px;
font-weight: bold;
text-align: center;
padding-top: 10px;
padding-bottom: 20px;
}
.content{
text-indent: 18px;
font-size: 16px;
line-height: 230%;
text-align: left;
}
.from{
font-size: 14px;
text-align: right;
padding-right: 15px;
padding-top: 15px;
}
.feature_bar{
font-size: 14px;
color:#999999;
text-align: center;
padding-bottom: 15px;
}
-->
</style>
</head>
<body>
<table width="80%">
<tr>
<td><div class="article_title">标题</div>
<div class="feature_bar">作者:录入时间:录入:</div>
<div class="content">内容</div>
<div class="from">来源:</div></td>
</tr>
</table>
</body>
</html>
把源代码中的所有的"替换成"",作用是在ASP中输出双引号。
设计asp文件:
<% Option Explicit%>
<html>
<head>
<title>ASP生成HTML</title>
<style type="text/css">
<!--
.align_right_top{
text-align: right;
vertical-align: top;
}
.align_left_10px{
text-align: left;
padding-left: 10px;
}
-->
</style>
</head>
<body>
<form method="post" action="?action=create">
<table width="80%">
<tr>
<td class="align_right_top">HTML文件名称:</td>
<td class="align_left_10px"><input name="HtmlFileName" type="text" id="HtmlFileName"/></td>
</tr>
<tr>
<td class="align_right_top">文章</td>
<td class="align_left_10px"><input name="title" type="text" id="title"/></td>
</tr>
<tr>
<td class="align_right_top">作者:</td>
<td class="align_left_10px"><input name="author" type="text" id="author"/></td>
</tr>
<tr>
<td class="align_right_top">录入:</td>
<td class="align_left_10px"><input name="editor" type="text" id="editor"/></td>
</tr>
<tr>
<td class="align_right_top">输入时间:</td>
<td class="align_left_10px"><input name="EditTime" type="text" id="EditTime"/></td>
</tr>
<tr>
<td class="align_right_top">文章内容:</td>
<td class="align_left_10px"><textarea name="content" cols="55" rows="20" id="content"></textarea></td>
</tr>
<tr>
<td class="align_right_top">来源:</td>
<td class="align_left_10px"><input name="from" type="text" id="from"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="提交"/></td>
</tr>
</table>
</form>
<%
if Trim(Request.QueryString("action"))="create" then
dim title, author, editor, EditTime, content, from, html
title=Trim(Request.Form("title"))
editor=Trim(Request.Form("editor"))
EditTime=Trim(Request.Form("EditTime"))
content=Trim(Request.Form("content"))
from=Trim(Request.Form("from"))
html="<html>"_'粘贴上面的修改后的输出网页布局的源代码
&"<head>"_‘并用 _与&把各行连接起来或删除多余空格使源代码写在一行
&"<title>"&title&"</title>"_
&"<style type=""text/css"">"_
&".article_title{"_
&"font-size: 22px;"_
&"font-weight: bold;"_
&"text-align: center;"_
&"padding-top: 10px;"_
&"padding-bottom: 20px;"_
&"}"_
&".content{"_
&"text-indent: 18px;"_
&"font-size: 16px;"_
&"line-height: 230%;"_
&"text-align: left;"_
&"}"_
&".from{"_
&"font-size: 14px;"_
&"text-align: right;"_
&"padding-right: 15px;"_
&"padding-top: 15px;"_
&"}"_
&".feature_bar{"_
&"font-size: 14px;"_
&"color:#999999;"_
&"text-align: center;"_
&"padding-bottom: 15px;"_
&"}"_
&"</style>"_
&"</head>"_
&"<body>"_
&"<table width=""80%"">"_
&"<tr>"_
&"<td><div class=""article_title"">"&title&"</div>"_
&"<div class=""feature_bar"">作者:"&author&"录入时间:"&EditTime&"录入:"&editor&"</div>"_
&"<div class=""content"">"&content&"</div>"_
&"<div class=""from"">来源:"&from&"</div></td>"_
&"</tr>"_
&"</table>"_
&"</body>"_
&"</html>"
dim HtmlFileName,HtmlFile, fs, FileStream
HtmlFileName=Trim(Request.Form("HtmlFileName"))
if instr(HtmlFileName,".html")=false then
HtmlFileName="NoName.html"
end if
HtmlFile=Server.MapPath(HtmlFileName)
set fs=CreateObject("Scripting.FileSystemObject")
set FileStream=fs.CreateTextFile(HtmlFile)
FileStream.WriteLine Html
FileStream.close
set FileStream=nothing
response.Write("<script>alert('生成"&HtmlFileName&"文件成功!');history.go(-1);</script>")
end if
%>
</body>
</htm>
把上面的asp文件保存放到服务器上即可运行
3)方式2:生成的内容基于模板生成
思想:
给模板asp传递参数,使用“MSXML2.XMLHTTP”读取基于参数传递的asp模板的网页源代码,
再使用FSO组件生成静态网页。
步骤:
a、设计有参数传递的asp模板
b、设计asp控制页
设计asp模板:(保存成template.asp)
<% Option Explicit%>
<%
dim HtmlFileName,title, author, editor,EditTime,content,from
HtmlFileName=Trim(Request.QueryString("HtmlFileName"))
title=Trim(Request.QueryString("title"))
author=Trim(Request.QueryString("author"))
editor=Trim(Request.QueryString("editor"))
EditTime=Trim(Request.QueryString("EditTime"))
content=Trim(Request.QueryString("content"))
from=Trim(Request.QueryString("from"))
%>
<html>
<head>
<title><%= title%></title>
<style type="text/css">
<!--
.article_title{
font-size: 22px;
font-weight: bold;
text-align: center;
padding-top: 10px;
padding-bottom: 20px;
}
.content{
text-indent: 18px;
font-size: 16px;
line-height: 230%;
text-align: left;
}
.from{
font-size: 14px;
text-align: right;
padding-right: 15px;
padding-top: 15px;
}
.feature_bar{
font-size: 14px;
color:#999999;
text-align: center;
padding-bottom: 15px;
}
-->
</style>
</head>
<body>
<table width="80%">
<tr>
<td><div class="article_title"><%= title%></div>
<div class="feature_bar">作者:<%= author%>录入时间:<%= EditTime%>录入:<%= editor%></div>
<div class="content"><%= content%></div>
<div class="from">来源:<%= from%></div></td>
</tr>
</table>
</body>
</html>
设计asp文件:(保存成html.asp)
<% Option Explicit%>
<html>
<head>
<title>ASP生成HTML</title>
<style type="text/css">
<!--
.align_right_top{
text-align: right;
vertical-align: top;
}
.align_left_10px{
text-align: left;
padding-left: 10px;
}
-->
</style>
</head>
<body>
<form method="post" action="?action=create">
<table width="80%">
<tr>
<td class="align_right_top">HTML文件名称:</td>
<td class="align_left_10px"><input name="HtmlFileName" type="text" id="HtmlFileName"/></td>
</tr>
<tr>
<td class="align_right_top">文章</td>
<td class="align_left_10px"><input name="title" type="text" id="title"/></td>
</tr>
<tr>
<td class="align_right_top">作者:</td>
<td class="align_left_10px"><input name="author" type="text" id="author"/></td>
</tr>
<tr>
<td class="align_right_top">录入:</td>
<td class="align_left_10px"><input name="editor" type="text" id="editor"/></td>
</tr>
<tr>
<td class="align_right_top">输入时间:</td>
<td class="align_left_10px"><input name="EditTime" type="text" id="EditTime"/></td>
</tr>
<tr>
<td class="align_right_top">文章内容:</td>
<td class="align_left_10px"><textarea name="content" cols="55" rows="20" id="content"></textarea></td>
</tr>
<tr>
<td class="align_right_top">来源:</td>
<td class="align_left_10px"><input name="from" type="text" id="from"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="提交"/></td>
</tr>
</table>
</form>
<%
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open"GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
Function BytesToBstr(body,Cset)
dim objstream
set objstream= Server.CreateObject("adodb.stream")
objstream.Type= 1
objstream.Mode=3
objstream.Open
objstream.Write body
objstream.Position= 0
objstream.Type= 2
objstream.Charset= Cset
BytesToBstr= objstream.ReadText
objstream.Close
set objstream= nothing
End Function
%>
<%
if Trim(Request.QueryString("action"))="create" then
dim title, author, editor, EditTime, content, from, html
title=Trim(Request.Form("title"))
editor=Trim(Request.Form("editor"))
EditTime=Trim(Request.Form("EditTime"))
content=Trim(Request.Form("content"))
from=Trim(Request.Form("from"))
'读取传递参数后的模版源代码,地址根据具体情况而定
html=getHTTPPage(""_
&"?title="&title&"&editor="&editor&"&EditTime="_
&EditTime&"&content="&content&"&from="&content&"")
dim HtmlFileName,HtmlFile, fs, FileStream
HtmlFileName=Trim(Request.Form("HtmlFileName"))
if instr(HtmlFileName,".html")=false then
HtmlFileName="NoName.html"
end if
HtmlFile=Server.MapPath(HtmlFileName)
set fs=CreateObject("Scripting.FileSystemObject")
set FileStream=fs.CreateTextFile(HtmlFile)
FileStream.WriteLine Html
FileStream.close
set FileStream=nothing
response.Write("<script>alert('生成"&HtmlFileName&"文件成功!');history.go(-1);</script>")
end if
%>
</body>
</htm>
把template.asp与html.asp放在同一目录通过服务器运行后即可。
4)结论
通过比较可以看出,通过方式一生成的html文件源代码比较乱,而通过模板生成的html文件源代码跟原先模板的源代码一致。
好了,关于asp网页源码和asp动态网页源码的问题到这里结束啦,希望可以解决您的问题哈!